diff --git a/CASA/include/micasa_mgmd.h b/CASA/include/micasa_mgmd.h index 18f1f450..460f0eb7 100644 --- a/CASA/include/micasa_mgmd.h +++ b/CASA/include/micasa_mgmd.h @@ -390,7 +390,7 @@ typedef struct _sscs_ext_t uint32_t ssFlags, // IN SSCS_SECRET_ID_T * appSecretID, // IN SSCS_SECRET_ID_T * sharedSecretID, // Optional IN - uint32_t * credentialType, // IN/OUT + uint32_t * credentialType, // IN/OUT void * credential, // OUT SSCS_EXT_T * ext // Reserved ); @@ -401,7 +401,7 @@ typedef struct _sscs_ext_t uint32_t ssFlags, // IN SSCS_SECRET_ID_T * appSecretID, // IN SSCS_SECRET_ID_T * sharedSecretID, // Optional IN - uint32_t credentialType, // IN + uint32_t credentialType, // IN void * credential, // IN SSCS_EXT_T * ext // Reserved ); diff --git a/CASA/micasad/lss/LocalStorage.cs b/CASA/micasad/lss/LocalStorage.cs index 9543d545..22388903 100644 --- a/CASA/micasad/lss/LocalStorage.cs +++ b/CASA/micasad/lss/LocalStorage.cs @@ -18,155 +18,155 @@ * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com. * - ***********************************************************************/ - -using System; -using System.IO; -using System.Text; -using System.Collections; -using System.Threading; -using System.Security.Cryptography; -using System.Xml; + ***********************************************************************/ + +using System; +using System.IO; +using System.Text; +using System.Collections; +using System.Threading; +using System.Security.Cryptography; +using System.Xml; #if LINUX using Mono.Unix.Native; -#endif -using sscs.cache; -using sscs.crypto; -using sscs.common; -using sscs.constants; -using Novell.CASA.MiCasa.Common; -using Novell.CASA.CASAPolicy; - -namespace sscs.lss -{ - /// - /* - * This class is a service to store data persistently. - * How it does this is determined by implementation within the - * private methods (File system using file(s), database, etc) - * The MasterPasscode can be used to generate the key for - * encyption and decryption. - * If encrpytion is used, the private methods will also manage - * how the encyption key is to be stored and retrieved. - * Each piece of data is located by a DataID. - * This might be an individual credentail or - * a complete store. - */ - - /* We might not need this as a separate class. - * Depending on the db changes, we can change this later. - */ - - /// - public class LocalStorage - { - private byte[] m_baGeneratedKey = null; - private SecretStore userStore = null; - - private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30; - private Thread persistThread = null; - private Thread sPersistThread = null; - +#endif +using sscs.cache; +using sscs.crypto; +using sscs.common; +using sscs.constants; +using Novell.CASA.MiCasa.Common; +using Novell.CASA.CASAPolicy; + +namespace sscs.lss +{ + /// + /* + * This class is a service to store data persistently. + * How it does this is determined by implementation within the + * private methods (File system using file(s), database, etc) + * The MasterPasscode can be used to generate the key for + * encyption and decryption. + * If encrpytion is used, the private methods will also manage + * how the encyption key is to be stored and retrieved. + * Each piece of data is located by a DataID. + * This might be an individual credentail or + * a complete store. + */ + + /* We might not need this as a separate class. + * Depending on the db changes, we can change this later. + */ + + /// + public class LocalStorage + { + private byte[] m_baGeneratedKey = null; + private SecretStore userStore = null; + + private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30; + private Thread persistThread = null; + private Thread sPersistThread = null; + #if LINUX Mono.Unix.UnixFileSystemInfo sockFileInfo; Mono.Unix.UnixUserInfo sockFileOwner; -#endif - - private static string LINUXID = "Unix"; - - internal LocalStorage(SecretStore store, byte[] baMasterPasscode, bool dummy) - { - userStore = store; - m_baGeneratedKey = baMasterPasscode; - LoadPersistentStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); - //userStore.DumpSecretstore(); - } - - internal LocalStorage(SecretStore store,byte[] baMasterPasscode) - { - userStore = store; - m_baGeneratedKey = baMasterPasscode; - LoadPersistentStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); - userStore.DumpSecretstore(); - } - - ~LocalStorage() - { - if(persistThread != null) - { - persistThread.Abort(); - persistThread.Join(); - } - - if(sPersistThread != null) - { - sPersistThread.Abort(); - sPersistThread.Join(); - } - } - - // allowing a user to choose the storage location is not approved yet - private LocalStorage(SecretStore store, - byte[] baMasterPasscode, string sStorageDirectory) - { - userStore = store; - m_baGeneratedKey = baMasterPasscode; - LoadPersistentStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); - userStore.DumpSecretstore(); - } - - private void StorePersistentData(string sDataID, byte[] baData) - { - - } - - private byte[] RetrievePersistentData(string sDataID) - { - - - return null; - } - - public void PersistStoreWithDelay() - { - if (persistThread == null) - { - persistThread = new Thread(new ThreadStart(PersistStoreDelayThreadFn)); - persistThread.Start(); - } - } - - public void PersistServerStoreWithDelay() - { - if (sPersistThread == null) - { - sPersistThread = new Thread(new ThreadStart(PersistServerStoreDelayThreadFn)); - sPersistThread.Start(); - } - } - - public bool StopPersistence() - { - if(persistThread != null) - { - persistThread.Abort(); - persistThread.Join(); - } - return true; - } - - public bool StopServerPersistence() - { - if(sPersistThread != null) - { - sPersistThread.Abort(); - sPersistThread.Join(); - } - return true; - } - - public bool IsOwnedByRoot(string fileName) - { +#endif + + private static string LINUXID = "Unix"; + + internal LocalStorage(SecretStore store, byte[] baMasterPasscode, bool dummy) + { + userStore = store; + m_baGeneratedKey = baMasterPasscode; + LoadPersistentStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); + //userStore.DumpSecretstore(); + } + + internal LocalStorage(SecretStore store, byte[] baMasterPasscode) + { + userStore = store; + m_baGeneratedKey = baMasterPasscode; + LoadPersistentStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); + userStore.DumpSecretstore(); + } + + ~LocalStorage() + { + if (persistThread != null) + { + persistThread.Abort(); + persistThread.Join(); + } + + if (sPersistThread != null) + { + sPersistThread.Abort(); + sPersistThread.Join(); + } + } + + // allowing a user to choose the storage location is not approved yet + private LocalStorage(SecretStore store, + byte[] baMasterPasscode, string sStorageDirectory) + { + userStore = store; + m_baGeneratedKey = baMasterPasscode; + LoadPersistentStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); + userStore.DumpSecretstore(); + } + + private void StorePersistentData(string sDataID, byte[] baData) + { + + } + + private byte[] RetrievePersistentData(string sDataID) + { + + + return null; + } + + public void PersistStoreWithDelay() + { + if (persistThread == null) + { + persistThread = new Thread(new ThreadStart(PersistStoreDelayThreadFn)); + persistThread.Start(); + } + } + + public void PersistServerStoreWithDelay() + { + if (sPersistThread == null) + { + sPersistThread = new Thread(new ThreadStart(PersistServerStoreDelayThreadFn)); + sPersistThread.Start(); + } + } + + public bool StopPersistence() + { + if (persistThread != null) + { + persistThread.Abort(); + persistThread.Join(); + } + return true; + } + + public bool StopServerPersistence() + { + if (sPersistThread != null) + { + sPersistThread.Abort(); + sPersistThread.Join(); + } + return true; + } + + public bool IsOwnedByRoot(string fileName) + { #if LINUX sockFileInfo = new Mono.Unix.UnixFileInfo(fileName); sockFileOwner = sockFileInfo.OwnerUser; @@ -174,194 +174,194 @@ namespace sscs.lss return true; else return false; -#else - return true; -#endif - } - - private string GetDecryptedServerSecretsXml() - { - try - { - string fileName = userStore.GetServerSecretsPersistenceFilePath(); - string tempFile = fileName; - int count = 0; - if(!File.Exists(fileName)) - { - while(true) - { - // check for tmp file - if (File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - { - File.Move(tempFile+".tmp", fileName); - break; - } - else - { - count++; - tempFile = fileName + count.ToString(); - } - } - else - return null; - - } - - // delete tmp file if there - if (File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - File.Delete(tempFile+".tmp"); - } - } - - byte[] baPasscode = null; - if (null != m_baGeneratedKey) - baPasscode = m_baGeneratedKey; - else - baPasscode = CASACrypto.GetServerMasterPasscodeUsingSystemKey(userStore.GetServerPasscodeBySystemKeyFilePath()); - - if( null == baPasscode ) - return null; - - byte[] key = CASACrypto.GetKeySetFromFile(baPasscode,userStore.GetServerKeyFilePath()); - if( null == key ) - return null; - - byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key,fileName); - - if( null == decryptedBuffer ) - return null; - - string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length); - - return temp; - } - catch(Exception e) - { - CSSSLogger.ExpLog(e.ToString()); - CSSSLogger.DbgLog("Unable to get persistent store"); - } - return null; - } - - private string GetDecryptedXml() - { - try - { - string fileName = userStore.GetPersistenceFilePath(); - string tempFile = fileName; - int count = 0; - if(!File.Exists(fileName)) - { - while(true) - { - // check for tmp file - if (File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - { - File.Move(tempFile+".tmp", fileName); - break; - } - else - { - count++; - tempFile = fileName + count.ToString(); - } - } - else - return null; - - } - - // delete tmp file if there - if (File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - File.Delete(tempFile+".tmp"); - } - } - - byte[] baPasscode = null; - if (null != m_baGeneratedKey) - baPasscode = m_baGeneratedKey; - else - baPasscode = CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()); - - if( null == baPasscode ) - return null; - - byte[] key = CASACrypto.GetKeySetFromFile(baPasscode,userStore.GetKeyFilePath()); - if( null == key ) - return null; - - byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key,fileName); - - if( null == decryptedBuffer ) - return null; - - string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length); - - return temp; - } - catch(Exception e) - { - CSSSLogger.ExpLog(e.ToString()); - CSSSLogger.DbgLog("Unable to get persistent store"); - } - return null; - } - - /* This method, uses the key to decrypt the persistent store - * and populates userStore with the persistent data. - */ - private bool LoadPersistentStore(string keyChainId) - { - try - { - //string xpath = ""; - XmlDocument doc = new XmlDocument(); - - string xmlToLoad = null; - if ( keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID ) - xmlToLoad = GetDecryptedXml(); - else if ( keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID ) - xmlToLoad = GetDecryptedServerSecretsXml(); - - if(xmlToLoad != null) - { - doc.LoadXml(xmlToLoad); - +#else + return true; +#endif + } + + private string GetDecryptedServerSecretsXml() + { + try + { + string fileName = userStore.GetServerSecretsPersistenceFilePath(); + string tempFile = fileName; + int count = 0; + if (!File.Exists(fileName)) + { + while (true) + { + // check for tmp file + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + { + File.Move(tempFile + ".tmp", fileName); + break; + } + else + { + count++; + tempFile = fileName + count.ToString(); + } + } + else + return null; + + } + + // delete tmp file if there + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + File.Delete(tempFile + ".tmp"); + } + } + + byte[] baPasscode = null; + if (null != m_baGeneratedKey) + baPasscode = m_baGeneratedKey; + else + baPasscode = CASACrypto.GetServerMasterPasscodeUsingSystemKey(userStore.GetServerPasscodeBySystemKeyFilePath()); + + if (null == baPasscode) + return null; + + byte[] key = CASACrypto.GetKeySetFromFile(baPasscode, userStore.GetServerKeyFilePath()); + if (null == key) + return null; + + byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key, fileName); + + if (null == decryptedBuffer) + return null; + + string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length); + + return temp; + } + catch (Exception e) + { + CSSSLogger.ExpLog(e.ToString()); + CSSSLogger.DbgLog("Unable to get persistent store"); + } + return null; + } + + private string GetDecryptedXml() + { + try + { + string fileName = userStore.GetPersistenceFilePath(); + string tempFile = fileName; + int count = 0; + if (!File.Exists(fileName)) + { + while (true) + { + // check for tmp file + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + { + File.Move(tempFile + ".tmp", fileName); + break; + } + else + { + count++; + tempFile = fileName + count.ToString(); + } + } + else + return null; + + } + + // delete tmp file if there + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + File.Delete(tempFile + ".tmp"); + } + } + + byte[] baPasscode = null; + if (null != m_baGeneratedKey) + baPasscode = m_baGeneratedKey; + else + baPasscode = CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(), userStore.GetPasscodeByDesktopFilePath()); + + if (null == baPasscode) + return null; + + byte[] key = CASACrypto.GetKeySetFromFile(baPasscode, userStore.GetKeyFilePath()); + if (null == key) + return null; + + byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key, fileName); + + if (null == decryptedBuffer) + return null; + + string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length); + + return temp; + } + catch (Exception e) + { + CSSSLogger.ExpLog(e.ToString()); + CSSSLogger.DbgLog("Unable to get persistent store"); + } + return null; + } + + /* This method, uses the key to decrypt the persistent store + * and populates userStore with the persistent data. + */ + private bool LoadPersistentStore(string keyChainId) + { + try + { + //string xpath = ""; + XmlDocument doc = new XmlDocument(); + + string xmlToLoad = null; + if (keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID) + xmlToLoad = GetDecryptedXml(); + else if (keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID) + xmlToLoad = GetDecryptedServerSecretsXml(); + + if (xmlToLoad != null) + { + doc.LoadXml(xmlToLoad); + #if false XmlTextWriter writer = new XmlTextWriter("d:/persist.xml",null); writer.Formatting = Formatting.Indented; doc.Save(writer); writer.Close(); -#endif - } - else - { - return false; - } - - // add these to the store - AddXMLSecretsToStore(userStore, doc); - } - catch(Exception e) - { - CSSSLogger.ExpLog(e.ToString()); - } - - // collect now to remove old data from memory - GC.Collect(); - - return true; - } - - internal static void AddXMLSecretsToStore(SecretStore userStore, XmlDocument doc) +#endif + } + else + { + return false; + } + + // add these to the store + AddXMLSecretsToStore(userStore, doc); + } + catch (Exception e) + { + CSSSLogger.ExpLog(e.ToString()); + } + + // collect now to remove old data from memory + GC.Collect(); + + return true; + } + + internal static void AddXMLSecretsToStore(SecretStore userStore, XmlDocument doc) { // get the conflict keychain KeyChain kcConflict; @@ -531,274 +531,274 @@ namespace sscs.lss }//end of traversing keyChainNodeList } - } + } + + private void PersistStoreDelayThreadFn() + { + Thread.Sleep(15000); + PersistStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); + persistThread = null; + } + + private void PersistServerStoreDelayThreadFn() + { + Thread.Sleep(15000); + PersistStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); + sPersistThread = null; + } + + private void PersistStoreThreadFn() + { + while (true) + { + Thread.Sleep(persistThreadSleepTime); + PersistStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); + } + } + + private void PersistServerStoreThreadFn() + { + while (true) + { + Thread.Sleep(persistThreadSleepTime); + PersistStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); + } + } + + /* Persists the store to an xml file. + * TBD : Would we require any form of encoding? + */ + + internal void PersistStore(string keyChainId) + { + string sPeristSecrets = null; + + // is policy set to persist secrets + UIPol uiPolicy = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL, userStore.GetUserHomeDirectory()); + if (uiPolicy != null) + { + sPeristSecrets = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_PERSIST_SECRETS); + } + + if ((sPeristSecrets != null) && (sPeristSecrets.Equals("0"))) + { + // delete .miCASA file and .IV file + if (keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID) + File.Delete(userStore.GetPersistenceFilePath()); + else if (keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID) + File.Delete(userStore.GetServerSecretsPersistenceFilePath()); + return; + } + + //userStore.DumpSecretstore(); + try + { + MemoryStream ms1 = GetSecretsAsXMLStream(this.userStore, keyChainId); + byte[] key = null; + string fileName = null; + + if (keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID) + { + key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath()); + fileName = userStore.GetPersistenceFilePath(); + } + else if (keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID) + { + key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetServerKeyFilePath()); + fileName = userStore.GetServerSecretsPersistenceFilePath(); + } + + string tempFile = fileName; + int count = 0; + + // rename existing file + if (File.Exists(fileName)) + { + while (true) + { + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + { + File.Delete(tempFile + ".tmp"); + break; + } + else + { + count++; + tempFile = fileName + count.ToString(); + } + } + else + break; + } + File.Move(fileName, tempFile + ".tmp"); + } + + CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(), key, fileName); + + //remove temp + if (File.Exists(tempFile + ".tmp")) + { + if (IsOwnedByRoot(tempFile + ".tmp")) + File.Delete(tempFile + ".tmp"); + } + } + catch (Exception e) + { + CSSSLogger.ExpLog(e.ToString()); + } + } + + internal static MemoryStream GetSecretsAsXMLStream(SecretStore userStore, string keyChainId) + { + try + { + MemoryStream ms1 = new MemoryStream(); + XmlTextWriter writer = new XmlTextWriter(ms1, null); + writer.Formatting = Formatting.Indented; + + writer.WriteStartDocument(); + writer.WriteStartElement(XmlConsts.miCASANode); + writer.WriteAttributeString(XmlConsts.versionAttr, "1.5"); + + IDictionaryEnumerator iter = (IDictionaryEnumerator)userStore.GetKeyChainEnumerator(); + char[] tmpId; + string sTmpId; + while (iter.MoveNext()) + { + KeyChain kc = (KeyChain)iter.Value; + string kcId = kc.GetKey(); + tmpId = new char[kcId.Length - 1]; + for (int i = 0; i < kcId.Length - 1; i++) + tmpId[i] = kcId[i]; + sTmpId = new string(tmpId); + + if ((keyChainId != null) && (keyChainId != sTmpId)) + continue; + + writer.WriteStartElement(XmlConsts.keyChainNode); + writer.WriteAttributeString(XmlConsts.idAttr, sTmpId); + // If we need to store time + writer.WriteStartElement(XmlConsts.timeNode); + writer.WriteAttributeString(XmlConsts.createdTimeNode, kc.CreatedTime.Ticks.ToString()); + writer.WriteAttributeString(XmlConsts.modifiedTimeNode, kc.ModifiedTime.Ticks.ToString()); + writer.WriteEndElement(); + + PersistencePol policy = null; + + IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kc.GetAllSecrets()); + while (secIter.MoveNext()) + { + Secret secret = (Secret)secIter.Value; + writer.WriteStartElement(XmlConsts.secretNode); + string secretId = secret.GetKey(); + + tmpId = new char[secretId.Length - 1]; + for (int i = 0; i < secretId.Length - 1; i++) + { + tmpId[i] = secretId[i]; + } + sTmpId = new string(tmpId); + + // TODO: Does Policy allow persisting this secret. + if (policy == null) + { + policy = (PersistencePol)ICASAPol.GetPolicy(CASAPolType.PERSISTENCE_POL, userStore.GetUserHomeDirectory()); + } + + bool bSaveValues = true; + if (policy != null) + { + if (policy.GetSecretPolicy(sTmpId, "Persistent", "True").Equals("False")) + { + //continue; + bSaveValues = false; + } + } + + writer.WriteAttributeString(XmlConsts.idAttr, sTmpId); + // If we need to store time + writer.WriteStartElement(XmlConsts.timeNode); + writer.WriteAttributeString(XmlConsts.createdTimeNode, secret.CreatedTime.Ticks.ToString()); + writer.WriteAttributeString("LazyTime", secret.CreatedTime.ToShortDateString()); + writer.WriteAttributeString(XmlConsts.modifiedTimeNode, secret.ModifiedTime.Ticks.ToString()); + writer.WriteEndElement(); + + writer.WriteStartElement(XmlConsts.valueNode); + // byte[] byteArr = secret.GetValue(); + + IDictionaryEnumerator etor = (IDictionaryEnumerator)secret.GetKeyValueEnumerator(); + while (etor.MoveNext()) + { + string sKey = (string)etor.Key; + string value = secret.GetKeyValue(sKey).GetValue(); + writer.WriteStartElement(XmlConsts.keyNode); + writer.WriteAttributeString(XmlConsts.idAttr, sKey); + writer.WriteStartElement(XmlConsts.keyValueNode); + + if (bSaveValues) + writer.WriteString(value); + else + writer.WriteString(""); + + writer.WriteEndElement(); + // If we need to store time + writer.WriteStartElement(XmlConsts.timeNode); + writer.WriteAttributeString(XmlConsts.createdTimeNode, (secret.GetKeyValueCreatedTime(sKey)).Ticks.ToString()); + writer.WriteAttributeString(XmlConsts.modifiedTimeNode, (secret.GetKeyValueModifiedTime(sKey)).Ticks.ToString()); + writer.WriteEndElement(); + + // write all LinkKeys + Hashtable htLinkedKeys = secret.GetLinkedKeys(sKey); + if (htLinkedKeys != null) + { + IDictionaryEnumerator etorLinked = (IDictionaryEnumerator)htLinkedKeys.GetEnumerator(); + while (etorLinked.MoveNext()) + { + LinkedKeyInfo lki = (LinkedKeyInfo)etorLinked.Value; + writer.WriteStartElement(XmlConsts.linkedKeyNode); + + writer.WriteStartElement(XmlConsts.linkedTargetSecretNode); + writer.WriteString(lki.GetLinkedSecretID().Substring(0, lki.GetLinkedSecretID().Length - 1)); + writer.WriteEndElement(); + + writer.WriteStartElement(XmlConsts.linkedTargetKeyNode); + writer.WriteString(lki.GetLinkedKeyID()); + writer.WriteEndElement(); + + writer.WriteEndElement(); + } + } + + writer.WriteEndElement(); + } + + /* + char[] chArr = new char[byteArr.Length]; + for(int z = 0; z < byteArr.Length; z++) + chArr[z] = (char)byteArr[z]; - private void PersistStoreDelayThreadFn() - { - Thread.Sleep(15000); - PersistStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); - persistThread = null; - } - - private void PersistServerStoreDelayThreadFn() - { - Thread.Sleep(15000); - PersistStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); - sPersistThread = null; - } - - private void PersistStoreThreadFn() - { - while(true) - { - Thread.Sleep(persistThreadSleepTime); - PersistStore(ConstStrings.SSCS_SESSION_KEY_CHAIN_ID); - } - } - - private void PersistServerStoreThreadFn() - { - while(true) - { - Thread.Sleep(persistThreadSleepTime); - PersistStore(ConstStrings.SSCS_SERVER_KEY_CHAIN_ID); - } - } - - /* Persists the store to an xml file. - * TBD : Would we require any form of encoding? - */ - - internal void PersistStore(string keyChainId) - { - string sPeristSecrets = null; - - // is policy set to persist secrets - UIPol uiPolicy = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL, userStore.GetUserHomeDirectory()); - if (uiPolicy != null) - { - sPeristSecrets = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_PERSIST_SECRETS); - } - - if ((sPeristSecrets != null) && (sPeristSecrets.Equals("0"))) - { - // delete .miCASA file and .IV file - if ( keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID ) - File.Delete(userStore.GetPersistenceFilePath()); - else if ( keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID ) - File.Delete(userStore.GetServerSecretsPersistenceFilePath()); - return; - } - - //userStore.DumpSecretstore(); - try - { - MemoryStream ms1 = GetSecretsAsXMLStream(this.userStore, keyChainId); - byte[] key = null; - string fileName = null; - - if ( keyChainId == ConstStrings.SSCS_SESSION_KEY_CHAIN_ID ) - { - key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath()); - fileName = userStore.GetPersistenceFilePath(); - } - else if ( keyChainId == ConstStrings.SSCS_SERVER_KEY_CHAIN_ID ) - { - key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetServerKeyFilePath()); - fileName = userStore.GetServerSecretsPersistenceFilePath(); - } - - string tempFile = fileName; - int count=0; - - // rename existing file - if(File.Exists(fileName)) - { - while(true) - { - if (File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - { - File.Delete(tempFile+".tmp"); - break; - } - else - { - count++; - tempFile = fileName + count.ToString(); - } - } - else - break; - } - File.Move(fileName, tempFile+".tmp"); - } - - CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(),key,fileName); - - //remove temp - if(File.Exists(tempFile+".tmp")) - { - if(IsOwnedByRoot(tempFile+".tmp")) - File.Delete(tempFile+".tmp"); - } - } - catch(Exception e) - { - CSSSLogger.ExpLog(e.ToString()); - } - } - - internal static MemoryStream GetSecretsAsXMLStream(SecretStore userStore, string keyChainId) - { - try - { - MemoryStream ms1 = new MemoryStream(); - XmlTextWriter writer = new XmlTextWriter(ms1,null); - writer.Formatting = Formatting.Indented; - - writer.WriteStartDocument(); - writer.WriteStartElement(XmlConsts.miCASANode); - writer.WriteAttributeString(XmlConsts.versionAttr,"1.5"); - - IDictionaryEnumerator iter = (IDictionaryEnumerator)userStore.GetKeyChainEnumerator(); - char [] tmpId; - string sTmpId; - while( iter.MoveNext() ) - { - KeyChain kc = (KeyChain)iter.Value; - string kcId = kc.GetKey(); - tmpId = new char[kcId.Length-1]; - for(int i = 0; i < kcId.Length-1; i++ ) - tmpId[i] = kcId[i]; - sTmpId = new string(tmpId); - - if( ( keyChainId != null ) && ( keyChainId != sTmpId )) - continue; - - writer.WriteStartElement(XmlConsts.keyChainNode); - writer.WriteAttributeString(XmlConsts.idAttr,sTmpId); - // If we need to store time - writer.WriteStartElement(XmlConsts.timeNode); - writer.WriteAttributeString(XmlConsts.createdTimeNode,kc.CreatedTime.Ticks.ToString()); - writer.WriteAttributeString(XmlConsts.modifiedTimeNode,kc.ModifiedTime.Ticks.ToString()); - writer.WriteEndElement(); - - PersistencePol policy = null; - - IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kc.GetAllSecrets()); - while(secIter.MoveNext()) - { - Secret secret = (Secret)secIter.Value; - writer.WriteStartElement(XmlConsts.secretNode); - string secretId = secret.GetKey(); - - tmpId = new char[secretId.Length-1]; - for(int i = 0; i < secretId.Length-1; i++ ) - { - tmpId[i] = secretId[i]; - } - sTmpId = new string(tmpId); - - // TODO: Does Policy allow persisting this secret. - if (policy == null) - { - policy = (PersistencePol)ICASAPol.GetPolicy(CASAPolType.PERSISTENCE_POL, userStore.GetUserHomeDirectory()); - } - - bool bSaveValues = true; - if (policy != null) - { - if (policy.GetSecretPolicy(sTmpId, "Persistent", "True").Equals("False")) - { - //continue; - bSaveValues = false; - } - } - - writer.WriteAttributeString(XmlConsts.idAttr,sTmpId); - // If we need to store time - writer.WriteStartElement(XmlConsts.timeNode); - writer.WriteAttributeString(XmlConsts.createdTimeNode,secret.CreatedTime.Ticks.ToString()); - writer.WriteAttributeString("LazyTime",secret.CreatedTime.ToShortDateString()); - writer.WriteAttributeString(XmlConsts.modifiedTimeNode,secret.ModifiedTime.Ticks.ToString()); - writer.WriteEndElement(); - - writer.WriteStartElement(XmlConsts.valueNode); - // byte[] byteArr = secret.GetValue(); - - IDictionaryEnumerator etor = (IDictionaryEnumerator)secret.GetKeyValueEnumerator(); - while(etor.MoveNext()) - { - string sKey = (string)etor.Key; - string value = secret.GetKeyValue(sKey).GetValue(); - writer.WriteStartElement(XmlConsts.keyNode); - writer.WriteAttributeString(XmlConsts.idAttr, sKey); - writer.WriteStartElement(XmlConsts.keyValueNode); - - if (bSaveValues) - writer.WriteString(value); - else - writer.WriteString(""); - - writer.WriteEndElement(); - // If we need to store time - writer.WriteStartElement(XmlConsts.timeNode); - writer.WriteAttributeString(XmlConsts.createdTimeNode,(secret.GetKeyValueCreatedTime(sKey)).Ticks.ToString()); - writer.WriteAttributeString(XmlConsts.modifiedTimeNode,(secret.GetKeyValueModifiedTime(sKey)).Ticks.ToString()); - writer.WriteEndElement(); - - // write all LinkKeys - Hashtable htLinkedKeys = secret.GetLinkedKeys(sKey); - if (htLinkedKeys != null) - { - IDictionaryEnumerator etorLinked = (IDictionaryEnumerator)htLinkedKeys.GetEnumerator(); - while(etorLinked.MoveNext()) - { - LinkedKeyInfo lki = (LinkedKeyInfo)etorLinked.Value; - writer.WriteStartElement(XmlConsts.linkedKeyNode); - - writer.WriteStartElement(XmlConsts.linkedTargetSecretNode); - writer.WriteString(lki.GetLinkedSecretID().Substring(0, lki.GetLinkedSecretID().Length-1)); - writer.WriteEndElement(); - - writer.WriteStartElement(XmlConsts.linkedTargetKeyNode); - writer.WriteString(lki.GetLinkedKeyID()); - writer.WriteEndElement(); - - writer.WriteEndElement(); - } - } - - writer.WriteEndElement(); - } - - /* - char[] chArr = new char[byteArr.Length]; - for(int z = 0; z < byteArr.Length; z++) - chArr[z] = (char)byteArr[z]; - - string stringToStore = new string(chArr); - writer.WriteString(stringToStore); - */ - - writer.WriteEndElement(); //end of value node - writer.WriteEndElement(); - } - writer.WriteEndElement(); //keychain - } - - writer.WriteEndElement(); //miCASA node - writer.WriteEndDocument(); - writer.Flush(); - writer.Close(); - return ms1; - } - catch (Exception e) - { - throw e; - } - } - } -} + string stringToStore = new string(chArr); + writer.WriteString(stringToStore); + */ + + writer.WriteEndElement(); //end of value node + writer.WriteEndElement(); + } + writer.WriteEndElement(); //keychain + } + + writer.WriteEndElement(); //miCASA node + writer.WriteEndDocument(); + writer.Flush(); + writer.Close(); + return ms1; + } + catch (Exception e) + { + throw e; + } + } + } +} diff --git a/CASA/package/windows/vs_solutions/CASA-msm/CASA-msm.vdproj b/CASA/package/windows/vs_solutions/CASA-msm/CASA-msm.vdproj index eb7fdcf2..3137a156 100644 --- a/CASA/package/windows/vs_solutions/CASA-msm/CASA-msm.vdproj +++ b/CASA/package/windows/vs_solutions/CASA-msm/CASA-msm.vdproj @@ -21,49 +21,19 @@ } "Entry" { - "MsmKey" = "8:_01EA198D017B971B145A17145CE2C5F6" - "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_01EA198D017B971B145A17145CE2C5F6" - "OwnerKey" = "8:_35D7FFD9A5F02B162343D1F3922ADB06" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { "MsmKey" = "8:_093DBD038821017381C58C1600BB65FF" "OwnerKey" = "8:_69B8715C6C864CE4BA0C8234D344175F" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_132F57540C1E9FCF17E2DF8360F4B09C" - "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" + "MsmKey" = "8:_11B0506C6E534CED95D82DA0A8EC9F82" + "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_132F57540C1E9FCF17E2DF8360F4B09C" - "OwnerKey" = "8:_35D7FFD9A5F02B162343D1F3922ADB06" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_132F57540C1E9FCF17E2DF8360F4B09C" - "OwnerKey" = "8:_01EA198D017B971B145A17145CE2C5F6" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_35D7FFD9A5F02B162343D1F3922ADB06" - "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_538816C3FDB46EF4059CBA054855C473" + "MsmKey" = "8:_4017F0313C0605FD76ED03402317EA35" "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" "MsmSig" = "8:_UNDEFINED" } @@ -75,12 +45,30 @@ } "Entry" { + "MsmKey" = "8:_657D0EB8D0C363240B7BB4B3F8031609" + "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_657D0EB8D0C363240B7BB4B3F8031609" + "OwnerKey" = "8:_4017F0313C0605FD76ED03402317EA35" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_69B8715C6C864CE4BA0C8234D344175F" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { + "MsmKey" = "8:_6C056EF6608CB813240B81AB2C290472" + "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_90C16B41FE7F435A8640BFDDD7C02619" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -93,6 +81,24 @@ } "Entry" { + "MsmKey" = "8:_E7B4BD63601426E59942ECD9791C92FE" + "OwnerKey" = "8:_C37A35F33FD14730BC7E7C47DF9C2DD1" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E7B4BD63601426E59942ECD9791C92FE" + "OwnerKey" = "8:_4017F0313C0605FD76ED03402317EA35" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E7B4BD63601426E59942ECD9791C92FE" + "OwnerKey" = "8:_657D0EB8D0C363240B7BB4B3F8031609" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_FCA9C6770F0FB28185373954659263CB" "OwnerKey" = "8:_01C1EAD583CE4AD39778A1F9EC86204D" "MsmSig" = "8:_UNDEFINED" @@ -106,25 +112,31 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_538816C3FDB46EF4059CBA054855C473" + "OwnerKey" = "8:_11B0506C6E534CED95D82DA0A8EC9F82" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_35D7FFD9A5F02B162343D1F3922ADB06" + "OwnerKey" = "8:_6C056EF6608CB813240B81AB2C290472" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_01EA198D017B971B145A17145CE2C5F6" + "OwnerKey" = "8:_4017F0313C0605FD76ED03402317EA35" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_132F57540C1E9FCF17E2DF8360F4B09C" + "OwnerKey" = "8:_657D0EB8D0C363240B7BB4B3F8031609" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_E7B4BD63601426E59942ECD9791C92FE" "MsmSig" = "8:_UNDEFINED" } } @@ -226,37 +238,6 @@ } "File" { - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_01EA198D017B971B145A17145CE2C5F6" - { - "AssemblyRegister" = "3:1" - "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:AppModule.NamedPipes, Version=1.6.0.19770, Culture=neutral, processorArchitecture=MSIL" - "ScatterAssemblies" - { - "_01EA198D017B971B145A17145CE2C5F6" - { - "Name" = "8:AppModule.NamedPipes.dll" - "Attributes" = "3:512" - } - } - "SourcePath" = "8:AppModule.NamedPipes.dll" - "TargetName" = "8:" - "Tag" = "8:" - "Folder" = "8:_24B477312C8840DB8DF8C1E373E7FC6D" - "Condition" = "8:" - "Transitive" = "11:FALSE" - "Vital" = "11:TRUE" - "ReadOnly" = "11:FALSE" - "Hidden" = "11:FALSE" - "System" = "11:FALSE" - "Permanent" = "11:FALSE" - "SharedLegacy" = "11:FALSE" - "PackageAs" = "3:1" - "Register" = "3:1" - "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" - "IsolateTo" = "8:" - } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_093DBD038821017381C58C1600BB65FF" { "SourcePath" = "8:micasa.dll" @@ -277,45 +258,14 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_132F57540C1E9FCF17E2DF8360F4B09C" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_4017F0313C0605FD76ED03402317EA35" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:AppModule.InterProcessComm, Version=1.6.0.19770, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Novell.CASA.Common, Version=1.6.2503.27769, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_132F57540C1E9FCF17E2DF8360F4B09C" - { - "Name" = "8:AppModule.InterProcessComm.dll" - "Attributes" = "3:512" - } - } - "SourcePath" = "8:AppModule.InterProcessComm.dll" - "TargetName" = "8:" - "Tag" = "8:" - "Folder" = "8:_24B477312C8840DB8DF8C1E373E7FC6D" - "Condition" = "8:" - "Transitive" = "11:FALSE" - "Vital" = "11:TRUE" - "ReadOnly" = "11:FALSE" - "Hidden" = "11:FALSE" - "System" = "11:FALSE" - "Permanent" = "11:FALSE" - "SharedLegacy" = "11:FALSE" - "PackageAs" = "3:1" - "Register" = "3:1" - "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" - "IsolateTo" = "8:" - } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_35D7FFD9A5F02B162343D1F3922ADB06" - { - "AssemblyRegister" = "3:1" - "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Novell.CASA.Common, Version=1.6.2495.19770, Culture=neutral, processorArchitecture=x86" - "ScatterAssemblies" - { - "_35D7FFD9A5F02B162343D1F3922ADB06" + "_4017F0313C0605FD76ED03402317EA35" { "Name" = "8:Novell.CASA.Common.dll" "Attributes" = "3:512" @@ -339,14 +289,45 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_538816C3FDB46EF4059CBA054855C473" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_657D0EB8D0C363240B7BB4B3F8031609" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Novell.CASA.CASAPol, Version=1.6.2495.19770, Culture=neutral, processorArchitecture=x86" + "AssemblyAsmDisplayName" = "8:AppModule.NamedPipes, Version=1.6.0.27768, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_538816C3FDB46EF4059CBA054855C473" + "_657D0EB8D0C363240B7BB4B3F8031609" + { + "Name" = "8:AppModule.NamedPipes.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:AppModule.NamedPipes.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_24B477312C8840DB8DF8C1E373E7FC6D" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_6C056EF6608CB813240B81AB2C290472" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Novell.CASA.CASAPol, Version=1.6.2501.25984, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_6C056EF6608CB813240B81AB2C290472" { "Name" = "8:Novell.CASA.CASAPol.dll" "Attributes" = "3:512" @@ -370,6 +351,37 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_E7B4BD63601426E59942ECD9791C92FE" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:AppModule.InterProcessComm, Version=1.6.0.25984, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_E7B4BD63601426E59942ECD9791C92FE" + { + "Name" = "8:AppModule.InterProcessComm.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:AppModule.InterProcessComm.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_24B477312C8840DB8DF8C1E373E7FC6D" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FCA9C6770F0FB28185373954659263CB" { "SourcePath" = "8:micasacache.dll" @@ -396,6 +408,17 @@ } "Folder" { + "{C7E34266-2C30-44B9-A9A3-4E394ABD6E18}:_1362415FE8D943B49FA4E4380970C97B" + { + "Name" = "8:#1927" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:GAC" + "Folders" + { + } + } "{1525181F-901A-416C-8A58-119130FE478E}:_4913CF477F8E455DA2D13A4A6892F4F7" { "Name" = "8:#1914" @@ -504,6 +527,34 @@ { } } + "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_11B0506C6E534CED95D82DA0A8EC9F82" + { + "SourcePath" = "8:..\\..\\..\\..\\sharp\\Novell.Casa\\obj\\Debug\\Novell.Casa.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_1362415FE8D943B49FA4E4380970C97B" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:1" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:Built" + "OutputProjectGuid" = "8:{7B56383F-6551-4BCD-81BB-A039BBECBD9C}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_53A2168DF64E4E9EB3FD5516424E732E" { "SourcePath" = "8:..\\..\\..\\..\\micasacache\\Debug\\micasacache.dll" @@ -562,7 +613,7 @@ } "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_90C16B41FE7F435A8640BFDDD7C02619" { - "SourcePath" = "8:..\\..\\..\\..\\logincapture\\windows\\bin\\debug\\lcredmgr.dll" + "SourcePath" = "8:..\\..\\..\\..\\logincapture\\windows\\bin\\Debug\\lcredmgr.dll" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_24B477312C8840DB8DF8C1E373E7FC6D" diff --git a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.ncb b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.ncb index 82e20590..85aa6cf6 100644 Binary files a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.ncb and b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.ncb differ diff --git a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.sln b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.sln index 65ac8bac..90af8378 100644 --- a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.sln +++ b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.sln @@ -1,7 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "CASA", "CASA.vdproj", "{C9DC01B9-DBA2-4894-9AA4-A747B71CA384}" -EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "CASA-dev-msm", "..\CASA-dev-msm\miCASA-Dev-msm.vdproj", "{51235A10-C83F-4B56-B16D-9DD695F9FB93}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cSample", "..\..\..\..\test\c_sample\CSample.vcproj", "{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}" @@ -15,14 +13,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lcredmgr", "..\..\..\..\Log EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Novell.CASA.miCASAWrapper", "..\..\..\..\sharp\NSSCSWrapper\Novell.CASA.miCASAWrapper.csproj", "{E21DD887-22F4-4935-9851-409715F663B0}" ProjectSection(ProjectDependencies) = postProject - {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} = {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} {E98F1F7E-40B6-44C8-AC66-EC867B141FA1} = {E98F1F7E-40B6-44C8-AC66-EC867B141FA1} + {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} = {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Novell.CASA.Common", "..\..\..\..\micasad\lib\Novell.CASA.Common.csproj", "{57CD94A2-5B4A-40C3-8189-CB760FB78357}" ProjectSection(ProjectDependencies) = postProject - {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} = {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} {E98F1F7E-40B6-44C8-AC66-EC867B141FA1} = {E98F1F7E-40B6-44C8-AC66-EC867B141FA1} + {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} = {077B53BB-404A-4B2F-BA17-AAE98C5E9C66} EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CASAManager", "..\..\..\..\gui\CASAManager.csproj", "{A1A805D0-B400-4D11-A772-348CE13F1046}" @@ -58,6 +56,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jmicasa", "..\..\..\..\jwra {99988A22-4C58-4BF7-A2DB-57761E76FB26} = {99988A22-4C58-4BF7-A2DB-57761E76FB26} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Novell.Casa.MiCasa", "..\..\..\..\sharp\Novell.Casa.MiCasa\Novell.Casa.MiCasa.csproj", "{7B56383F-6551-4BCD-81BB-A039BBECBD9C}" +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "CASA", "CASA.vdproj", "{288987CA-24A3-443B-A9D4-018CCF47C9C3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,18 +70,6 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Any CPU.ActiveCfg = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Any CPU.Build.0 = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Mixed Platforms.ActiveCfg = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Mixed Platforms.Build.0 = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Win32.ActiveCfg = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Debug|Win32.Build.0 = Debug - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Any CPU.ActiveCfg = Release - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Any CPU.Build.0 = Release - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Mixed Platforms.ActiveCfg = Release - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Mixed Platforms.Build.0 = Release - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Win32.ActiveCfg = Release - {C9DC01B9-DBA2-4894-9AA4-A747B71CA384}.Release|Win32.Build.0 = Release {51235A10-C83F-4B56-B16D-9DD695F9FB93}.Debug|Any CPU.ActiveCfg = Debug {51235A10-C83F-4B56-B16D-9DD695F9FB93}.Debug|Any CPU.Build.0 = Debug {51235A10-C83F-4B56-B16D-9DD695F9FB93}.Debug|Mixed Platforms.ActiveCfg = Debug @@ -266,6 +256,28 @@ Global {D2BD9955-65B4-4E34-B178-52D71444AE63}.Release|Mixed Platforms.Build.0 = Release|Win32 {D2BD9955-65B4-4E34-B178-52D71444AE63}.Release|Win32.ActiveCfg = Release|Win32 {D2BD9955-65B4-4E34-B178-52D71444AE63}.Release|Win32.Build.0 = Release|Win32 + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Debug|Win32.ActiveCfg = Debug|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Release|Any CPU.Build.0 = Release|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7B56383F-6551-4BCD-81BB-A039BBECBD9C}.Release|Win32.ActiveCfg = Release|Any CPU + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Any CPU.ActiveCfg = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Any CPU.Build.0 = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Mixed Platforms.ActiveCfg = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Mixed Platforms.Build.0 = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Win32.ActiveCfg = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Debug|Win32.Build.0 = Debug + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Any CPU.ActiveCfg = Release + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Any CPU.Build.0 = Release + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Mixed Platforms.ActiveCfg = Release + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Mixed Platforms.Build.0 = Release + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Win32.ActiveCfg = Release + {288987CA-24A3-443B-A9D4-018CCF47C9C3}.Release|Win32.Build.0 = Release EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.suo b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.suo index 05331695..71b0d1ea 100644 Binary files a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.suo and b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.suo differ diff --git a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.vdproj b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.vdproj index 0e5ca76a..aaddb1a3 100644 --- a/CASA/package/windows/vs_solutions/CASA32-msi/CASA.vdproj +++ b/CASA/package/windows/vs_solutions/CASA32-msi/CASA.vdproj @@ -162,7 +162,7 @@ "Name" = "8:.NET Framework" "Message" = "8:[VSDNETMSG]" "Version" = "8:2.0.50727" - "AllowLaterVersions" = "11:FALSE" + "AllowLaterVersions" = "11:TRUE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=9832" "SupportedRuntimes" = "8:1.1.4322;2.0.50727" } @@ -333,14 +333,14 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:CASA" - "ProductCode" = "8:{49AB55EE-5DBD-4992-BC39-65AFFB00C125}" - "PackageCode" = "8:{B65108A7-B1EC-488A-8A4F-0E2FFF469C13}" + "ProductCode" = "8:{EA80E3ED-8B3E-41AA-8140-DB41B224A280}" + "PackageCode" = "8:{841F0620-06FE-48EC-A8D0-271C720A5DB7}" "UpgradeCode" = "8:{DFD8B8A0-EA51-4202-831C-7CD2B90A63AE}" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" - "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.7.936" + "InstallAllUsers" = "11:TRUE" + "ProductVersion" = "8:1.7.956" "Manufacturer" = "8:Novell" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" @@ -871,7 +871,7 @@ { "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_98DCC664712A41B993FCD33026D06FFC" { - "SourcePath" = "8:..\\CASA-gui-msm\\Release\\CASA-gui.msm" + "SourcePath" = "8:..\\CASA-gui-msm\\Debug\\CASA-gui.msm" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_E8900D5F0BD44DC0BB0BEFDF7C43B30C" @@ -924,7 +924,7 @@ } "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_A6D188F9B5AF430C92D0B9606ADF4C63" { - "SourcePath" = "8:..\\CASA-dev-msm\\Release\\miCASA-Dev-msm.msm" + "SourcePath" = "8:..\\CASA-dev-msm\\Debug\\miCASA-Dev-msm.msm" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_E8900D5F0BD44DC0BB0BEFDF7C43B30C" @@ -1047,7 +1047,7 @@ } "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BF2CE61978054B2DB482792974E390F0" { - "SourcePath" = "8:..\\CASA-msm\\Release\\CASA-msm.msm" + "SourcePath" = "8:..\\CASA-msm\\Debug\\CASA-msm.msm" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_E8900D5F0BD44DC0BB0BEFDF7C43B30C" diff --git a/CASA/readme-folder/readme-win.txt b/CASA/readme-folder/readme-win.txt index df62b3c4..2563b87e 100644 --- a/CASA/readme-folder/readme-win.txt +++ b/CASA/readme-folder/readme-win.txt @@ -122,7 +122,7 @@ distribution (.tar.gz) file, use configure. (run ./configure --help for more options) 4. Choose your make target, here are a few interesting ones: -make - compile and create binaries +make - compile and create binaries, and setup files. make clean - clean up binaries diff --git a/CASA/sharp/Novell.Casa.MiCasa/BasicCredential.cs b/CASA/sharp/Novell.Casa.MiCasa/BasicCredential.cs new file mode 100644 index 00000000..af9b5f95 --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/BasicCredential.cs @@ -0,0 +1,52 @@ +/*********************************************************************** + * + * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library 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 + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + ***********************************************************************/ + +using System; + +namespace Novell.Casa +{ + /// + /// Summary description for BasicCredential. + /// + public class BasicCredential + { + + private string m_username = ""; + private string m_password = ""; + + public BasicCredential(string username, string password) + { + m_username = username; + m_password = password; + } + + public string GetUsername() + { + return m_username; + } + + public string GetPassword() + { + return m_password; + } + } +} \ No newline at end of file diff --git a/CASA/sharp/Novell.Casa.MiCasa/Casa.snk b/CASA/sharp/Novell.Casa.MiCasa/Casa.snk new file mode 100644 index 00000000..9e8f3e2f Binary files /dev/null and b/CASA/sharp/Novell.Casa.MiCasa/Casa.snk differ diff --git a/CASA/sharp/Novell.Casa.MiCasa/MiCasa.cs b/CASA/sharp/Novell.Casa.MiCasa/MiCasa.cs new file mode 100644 index 00000000..83f376e6 --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/MiCasa.cs @@ -0,0 +1,141 @@ +/*********************************************************************** + * + * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library 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 + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + ***********************************************************************/ + + +using System; +using Novell.Casa; + +namespace Novell.Casa +{ + /// + /// Summary description for miCASA. + /// + public class MiCasa + { + public static uint USERNAME_TYPE_CN_F = 0x00000000; + public static uint USERNAME_TYPE_NDS_DN_F = 0x00000001; + public static uint USERNAME_TYPE_NDS_FDN_F = 0x00000002; + public static uint USERNAME_TYPE_LDAP_DN_F = 0x00000004; + public static uint USERNAME_TYPE_EMAIL_F = 0x00000008; + public static uint USERNAME_TYPE_OTHER_F = 0x00000010; + + public MiCasa() + { + // + // TODO: Add constructor logic here + // + } + + + public static void SetBasicCredential( + string sAppSecretID, + string sSharedSecretID, + string sUsername, + string sPassword) + { + SetCredential(0, sAppSecretID, sSharedSecretID, 0, sUsername, sPassword); + } + + public static string GetCredentialUsername( + string sAppSecretID, + string sSharedSecretID) + + { + BasicCredential bc = GetBasicCredential(sAppSecretID, sSharedSecretID); + if (bc != null) + return bc.GetUsername(); + else + return null; + } + + public static string GetCredentialPassword( + string sAppSecretID, + string sSharedSecretID) + + { + BasicCredential bc = GetBasicCredential(sAppSecretID, sSharedSecretID); + if (bc != null) + return bc.GetPassword(); + else + return null; + } + + + public static BasicCredential GetBasicCredential( + string sAppSecretID, + string sSharedSecretID) + { + return GetCredential(0, sAppSecretID, sSharedSecretID, MiCasa.USERNAME_TYPE_CN_F); + } + + public static void RemoveBasicCredential( + string sAppSecretID, + string sSharedSecretID) + { + RemoveCredential(0, sAppSecretID, sSharedSecretID); + } + + + public static void SetCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID, + uint unFlag, + string sUsername, + string sPassword) + { + NativeCalls.SetCredential(ssFlags, sAppSecretID, sSharedSecretID, unFlag, NativeCalls.SSCS_CRED_TYPE_BASIC_F, sUsername, sPassword); + } + + public static BasicCredential GetCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID, + uint unFlag) + + { + return NativeCalls.GetCredential(ssFlags, sAppSecretID, sSharedSecretID, unFlag, NativeCalls.SSCS_CRED_TYPE_BASIC_F); + } + + public static void RemoveCredential( + string sAppSecretID) + { + RemoveCredential(0, sAppSecretID, null); + } + + public static void RemoveCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID) + { + NativeCalls.RemoveCredential(ssFlags, sAppSecretID, sSharedSecretID); + } + + + public static bool IsSecretPersistent( + uint ssFlags, + string secretID) + { + return NativeCalls.IsSecretPersistent(ssFlags,secretID); + } + } +} diff --git a/CASA/sharp/Novell.Casa.MiCasa/MiCasaException.cs b/CASA/sharp/Novell.Casa.MiCasa/MiCasaException.cs new file mode 100644 index 00000000..0be8a1f9 --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/MiCasaException.cs @@ -0,0 +1,520 @@ +/*********************************************************************** + * + * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library 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 + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + ***********************************************************************/ + +using System; + +namespace Novell.Casa +{ + /// + /// Summary description for MiCasaException. + /// + public class MiCasaException:Exception + { + + int m_iException = 0; + + public const int NSSCS_E_OBJECT_NOT_FOUND = -800; //0xFFFFFCE0; /* -800 */ + + /** + * NICI operations have failed. + */ + public const int NSSCS_E_NICI_FAILURE = -801; + + /** + * Secret ID is not in the User Secret Store. + */ + public const int NSSCS_E_INVALID_SECRET_ID = -802; + + /** + * Some internal operating system services have not been available. + */ + public const int NSSCS_E_SYSTEM_FAILURE = -803; + + /** + * Access to the target SecretStore has been denied. + */ + public const int NSSCS_E_ACCESS_DENIED = -804; + + /** + * Some internal NDS services have not been available. + */ + public const int NSSCS_E_NDS_INTERNAL_FAILURE = -805; + + /** + * Secret has not been initialized with a write. + */ + public const int NSSCS_E_SECRET_UNINITIALIZED = -806; + + /** + * Size of the buffer is not in a nominal range between minimum and maximum. + */ + public const int NSSCS_E_BUFFER_LEN = -807; + + /** + * Client and server components are not of the compatible versions. + */ + public const int NSSCS_E_INCOMPATIBLE_VERSION = -808; + + /** + * SecretStore data on the server has been corrupted. + */ + public const int NSSCS_E_CORRUPTED_STORE = -809; + + /** + * Secret ID already exists in the Secret Store. + */ + public const int NSSCS_E_SECRET_ID_EXISTS = -810; + + /** + * User NDS password has been changed by the administrator. + */ + public const int NSSCS_E_NDS_PWORD_CHANGED = -811; + + /** + * Target NDS User object not found. + */ + public const int NSSCS_E_INVALID_TARGET_OBJECT = -812; + + /** + * Target NDS User object does not have a SecretStore. + */ + public const int NSSCS_E_STORE_NOT_FOUND = -813; + + /** + * SecretStore not on the Network. + */ + public const int NSSCS_E_SERVICE_NOT_FOUND = -814; + + /** + * Length of the Secret ID buffer exceeds the limit. + */ + public const int NSSCS_E_SECRET_ID_TOO_LONG = -815; + + /** + * Length of the Enumeration buffer too int. + */ + public const int NSSCS_E_ENUM_BUFF_TOO_SHORT = -816; + + /** + * User not authenticated. + */ + public const int NSSCS_E_NOT_AUTHENTICATED = -817; + + /** + * Not supported operations. + */ + public const int NSSCS_E_NOT_SUPPORTED = -818; + + /** + * Typed in NDS password not valid. + */ + public const int NSSCS_E_NDS_PWORD_INVALID = -819; + + /** + * Session keys of the client and server NICI are out of sync. + */ + public const int NSSCS_E_NICI_OUTOF_SYNC = -820; + + /** + * Requested service not supported yet. + */ + public const int NSSCS_E_SERVICE_NOT_SUPPORTED = -821; + + /** + * NDS authentication type not supported. + */ + public const int NSSCS_E_TOKEN_NOT_SUPPORTED = -822; + + /** + * Unicode text conversion operation failed. + */ + public const int NSSCS_E_UNICODE_OP_FAILURE = -823; + + /** + * Connection to server is lost. + */ + public const int NSSCS_E_TRANSPORT_FAILURE = -824; + + /** + * Cryptographic operation failed. + */ + public const int NSSCS_E_CRYPTO_OP_FAILURE = -825; + + /** + * Opening a connection to the server failed. + */ + public const int NSSCS_E_SERVER_CONN_FAILURE = -826; + + /** + * Access to server connection failed. + */ + public const int NSSCS_E_CONN_ACCESS_FAILURE = -827; + + /** + * Size of the enumeration buffer exceeds the limit. + */ + public const int NSSCS_E_ENUM_BUFF_TOO_LONG = -828; + + /** + * Size of the Secret buffer exceeds the limit. + */ + public const int NSSCS_E_SECRET_BUFF_TOO_LONG = -829; + + /** + * Length of the Secret ID should be greater than zero. + */ + public const int NSSCS_E_SECRET_ID_TOO_SHORT = -830; + + /** + * Protocol data corrupted on the wire. + */ + public const int NSSCS_E_CORRUPTED_PACKET_DATA = -831; + + /** + * EP password validation failed. Access to the secret denied! + */ + public const int NSSCS_E_EP_ACCESS_DENIED = -832; + + /** + * Schema is not extended to support SecreStore on the target tree. + */ + public const int NSSCS_E_SCHEMA_NOT_EXTENDED = -833; + + /** + * One of the optional service attributes is not instantiated. + */ + public const int NSSCS_E_ATTR_NOT_FOUND = -834; + + /** + * Server has been upgraded and user SecretStore should be updated. + */ + public const int NSSCS_E_MIGRATION_NEEDED = -835; + + /** + * Master password could not be verified to read or unlock the secrets. + */ + public const int NSSCS_E_MP_PWORD_INVALID = -836; + + /** + * Master password has not been set on the SecretStore. + */ + public const int NSSCS_E_MP_PWORD_NOT_SET = -837; + + /** + * Ability to use master password has been disabled. + */ + public const int NSSCS_E_MP_PWORD_NOT_ALLOWED = -838; + + /** + * Not a writeable replica of NDS. + */ + public const int NSSCS_E_WRONG_REPLICA_TYPE = -839; + + /** + * Target attribute is not instantiated in NDS. + * + * @since 3.0 + */ + public const int NSSCS_E_ATTR_VAL_NOT_FOUND = -840; + + /** + * API parameter is not initialized. + * + * @since 3.0 + */ + public const int NSSCS_E_INVALID_PARAM = -841; + + /** + * Connection to SecretStore needs to be over SSL. + * + * @since 3.0 + */ + public const int NSSCS_E_NEED_SECURE_CHANNEL = -842; + + /** + * No server to support the given override configuration is found. + * + * @since 3.02 + */ + public const int NSSCS_E_CONFIG_NOT_SUPPORTED = -843; + + /** + * Attempt to unlock SecretStore failed because the store is not locked. + * + * @since 3.02 + */ + public const int NSSCS_E_STORE_NOT_LOCKED = -844; + + /** + * NDS Replica on the server that holds SecretStore is out of sync with the replica ring. + * + * @since 3.2 + */ + public const int NSSCS_E_TIME_OUT_OF_SYNC = -845; + + /** + * Versions of the client dlls don't match. + * + * @since 3.2 + */ + public const int NSSCS_E_VERSION_MISMATCH = -846; + + /** + * Buffer supplied for the secret is too short. + * + * @since 3.2 + */ + public const int NSSCS_E_SECRET_BUFF_TOO_SHORT = -847; + + /** + * Shared Secret processing and operations failed. + * + * @since 3.2 + */ + public const int NSSCS_E_SH_SECRET_FAILURE = -848; + + /** + * Shared Secret parser operations failed. + * + * @since 3.2 + */ + public const int NSSCS_E_PARSER_FAILURE = -849; + + /** + * Utf8 string operations failed. + * + * @since 3.2 + */ + public const int NSSCS_E_UTF8_OP_FAILURE = -850; + + /** + * Contextless name for LDAP bind does not resolve to a unique DN. + * + * @since 3.2 + */ + public const int NSSCS_E_CTX_LESS_CN_NOT_UNIQUE = -851; + + /** + * Feature not implemented yet. + */ + public const int NSSCS_E_NOT_IMPLEMENTED = -888; + + /** + * Product's BETA life has expired! Official release copy should be purchased. + */ + public const int NSSCS_E_BETA_EXPIRED = -899; + + + public MiCasaException() + { + // + // TODO: Add constructor logic here + // + } + + public MiCasaException(int iException) + { + m_iException = iException; + } + + public string getMessage() + { + return getMessage(m_iException); + } + + public int getErrorCode() + { + return m_iException; + } + + public string getMessage(int iException) + { + switch (iException) + { + case NSSCS_E_OBJECT_NOT_FOUND: + return "Can't find the target object DN in NDS"; + + case NSSCS_E_NICI_FAILURE: + return "NICI operations have failed"; + + case NSSCS_E_INVALID_SECRET_ID: + return "Secret ID is not in the User Secret Store"; + + case NSSCS_E_SYSTEM_FAILURE: + return "Some internal operating system services have not been available"; + + case NSSCS_E_ACCESS_DENIED: + return "Access to the target SecretStore has been denied"; + + case NSSCS_E_NDS_INTERNAL_FAILURE: + return "Some internal NDS services have not been available"; + + case NSSCS_E_SECRET_UNINITIALIZED: + return "Secret has not been initialized with a write"; + + case NSSCS_E_BUFFER_LEN: + return "Size of the buffer is not in a nominal range between minimum and maximum"; + + case NSSCS_E_INCOMPATIBLE_VERSION: + return "Client and server components are not of the compatible versions"; + + case NSSCS_E_CORRUPTED_STORE: + return "SecretStore data on the server has been corrupted"; + + case NSSCS_E_SECRET_ID_EXISTS: + return "Secret ID is already in SecretStore"; + + case NSSCS_E_NDS_PWORD_CHANGED: + return "User NDS password has been changed by the administrator"; + + case NSSCS_E_INVALID_TARGET_OBJECT: + return "Target NDS User object not found"; + + case NSSCS_E_STORE_NOT_FOUND: + return "Target NDS User object does not have a SecretStore"; + + case NSSCS_E_SERVICE_NOT_FOUND: + return "SecretStore not on the Network"; + + case NSSCS_E_SECRET_ID_TOO_LONG: + return "Length of the Secret ID buffer exceeds the limit"; + + case NSSCS_E_ENUM_BUFF_TOO_SHORT: + return "Length of the Enumeration buffer too short"; + + case NSSCS_E_NOT_AUTHENTICATED: + return "User not authenticated"; + + case NSSCS_E_NOT_SUPPORTED: + return "Not supported operations"; + + case NSSCS_E_NDS_PWORD_INVALID: + return "Typed in NDS password not valid"; + + case NSSCS_E_NICI_OUTOF_SYNC: + return "Session keys of the client and server NICI are out of sync"; + + case NSSCS_E_SERVICE_NOT_SUPPORTED: + return "Requested service not supported yet"; + + case NSSCS_E_TOKEN_NOT_SUPPORTED: + return "NDS authentication type not supported"; + + case NSSCS_E_UNICODE_OP_FAILURE: + return "Unicode text conversion operation failed"; + + case NSSCS_E_TRANSPORT_FAILURE: + return "Connection to server is lost"; + + case NSSCS_E_CRYPTO_OP_FAILURE: + return "Cryptographic operation failed"; + + case NSSCS_E_SERVER_CONN_FAILURE: + return "Opening a connection to the server failed"; + + case NSSCS_E_CONN_ACCESS_FAILURE: + return "Access to server connection failed"; + + case NSSCS_E_ENUM_BUFF_TOO_LONG: + return "Size of the enumeration buffer exceeds the limit"; + + case NSSCS_E_SECRET_BUFF_TOO_LONG: + return "Size of the Secret buffer exceeds the limit"; + + case NSSCS_E_SECRET_ID_TOO_SHORT: + return "Length of the Secret ID should be greater than zero"; + + case NSSCS_E_CORRUPTED_PACKET_DATA: + return "Protocol data corrupted on the wire"; + + case NSSCS_E_EP_ACCESS_DENIED: + return "EP password validation failed. Access to the secret denied"; + + case NSSCS_E_SCHEMA_NOT_EXTENDED: + return "Schema is not extended to support SecreStore on the target tree"; + + case NSSCS_E_ATTR_NOT_FOUND: + return "One of the optional service attributes is not instantiated"; + + case NSSCS_E_MIGRATION_NEEDED: + return "Server has been upgraded and user SecretStore should be updated"; + + case NSSCS_E_MP_PWORD_INVALID: + return "Master password could not be verified to read or unlock the secrets"; + + case NSSCS_E_MP_PWORD_NOT_SET: + return "Master password has not been set on the SecretStore"; + + case NSSCS_E_MP_PWORD_NOT_ALLOWED: + return "Ability to use master password has been disabled"; + + case NSSCS_E_WRONG_REPLICA_TYPE: + return "Not a writeable replica of NDS"; + + case NSSCS_E_ATTR_VAL_NOT_FOUND: + return "Target attribute is not instantiated in NDS"; + + case NSSCS_E_INVALID_PARAM: + return "API parameter is not initialized"; + + case NSSCS_E_NEED_SECURE_CHANNEL: + return "Connection to SecretStore needs to be over SSL"; + + case NSSCS_E_CONFIG_NOT_SUPPORTED: + return "No server to support the given override configuration is found"; + + case NSSCS_E_STORE_NOT_LOCKED: + return "Attempt to unlock SecretStore failed because the store is not locked"; + + case NSSCS_E_TIME_OUT_OF_SYNC: + return "NDS Replica on the server that holds SecretStore is out of sync with the replica ring"; + + case NSSCS_E_VERSION_MISMATCH: + return "Versions of the client dlls don't match"; + + case NSSCS_E_SECRET_BUFF_TOO_SHORT: + return "Buffer supplied for the secret is too short"; + + case NSSCS_E_SH_SECRET_FAILURE: + return "Shared Secret processing and operations failed"; + + case NSSCS_E_PARSER_FAILURE: + return "Shared Secret parser operations failed"; + + case NSSCS_E_UTF8_OP_FAILURE: + return "Utf8 string operations failed"; + + case NSSCS_E_CTX_LESS_CN_NOT_UNIQUE: + return "Contextless name for LDAP bind does not resolve to a unique DN"; + + case NSSCS_E_NOT_IMPLEMENTED: + return "Feature not implemented yet"; + + case NSSCS_E_BETA_EXPIRED: + return "Product's BETA life has expired! Official release copy should be purchased"; + } + + return ""; + + } + } +} diff --git a/CASA/sharp/Novell.Casa.MiCasa/NativeCalls.cs b/CASA/sharp/Novell.Casa.MiCasa/NativeCalls.cs new file mode 100644 index 00000000..17888e3b --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/NativeCalls.cs @@ -0,0 +1,474 @@ +/*********************************************************************** + * + * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library 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 + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + ***********************************************************************/ + +using System; +using System.Runtime.InteropServices; +using System.Text; +using System.Collections.Specialized; +using System.Collections; + +namespace Novell.Casa +{ + /// + /// Summary description for NativeCalls. + /// + public class NativeCalls + { + private static SSCS_KEYCHAIN_ID_T DefaultKeychainID = null; + internal static uint SSCS_CRED_TYPE_BASIC_F = 1; + internal static uint SSCS_CRED_TYPE_SERVER_F = 4; + private static int USERNAME_LEN = 256; + private static int PASSWORD_LEN = 128; + + public NativeCalls() + { + // + // TODO: Add constructor logic here + // + if (DefaultKeychainID == null) + { + DefaultKeychainID = new SSCS_KEYCHAIN_ID_T(); + } + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_PASSWORD_T + { + public uint pwordType; + public uint pwordLen; // * enhanced protection len & pword to set + // [MarshalAs(UnmanagedType.LPStr, SizeConst = 128)] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string pword; // * should be passed in # of chars + } ; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_KEYCHAIN_ID_T + { + public int len; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] + public string keychainID; + }; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_SH_SECRET_ID_T + { + public int type; // The shared secret type i.e. SS_App or SS_CredSet + public int len; // except that it excludes the header and is not escaped. + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] + public string name; // The shared secret name. This is the same as the identifier + }; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_SECRET_STORE_ID_T + { + public int version; // * max id len in bytes + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] + public string id; // * should be passed in # of chars + }; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_SECRET_ID_T + { + public int len; // * max id len in bytes + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] + public string id; // * should be passed in # of chars + }; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_EXT_T + { + public int extID; // defined to identify the extension + public int version; // defined as the version of the specified extension + public IntPtr ext; // points to the actual extension + } ; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_CONTEXT_T + { + public int version; + public int flags; + public SSCS_SECRET_ID_T ssid; + public UInt64 ssHandle; + }; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class SSCS_BASIC_CREDENTIAL_UTF8 + { + public uint unFlags; + public uint unLen; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] + public byte[] username; + public uint pwordLen; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public byte[] password; + } + + // * The following functions will be exposed as exported API: + // ************************************************************** + // * These function calls will utilize the Support Functions for + // * populating or extracting data from a Shared Secret. + // ************************************************************** + + private const string NDK_LIBRARY = "micasa"; + + [DllImport(NDK_LIBRARY)] + internal static extern int miCASAGetCredential + ( + [In] uint ssFlags, + [In] SSCS_SECRET_ID_T appSecretID, + [In] SSCS_SECRET_ID_T sharedSecretID, + [In, Out] ref uint credentialType, + [In, Out] IntPtr pCredential, + [In, Out] SSCS_EXT_T ext + ); + + + [DllImport(NDK_LIBRARY)] + internal static extern int miCASASetCredential + ( + [In] uint ssFlags, + [In] SSCS_SECRET_ID_T appSecretID, + [In] SSCS_SECRET_ID_T sharedSecretID, + [In] uint credentialType, + [In] IntPtr credential, + [In, Out] SSCS_EXT_T ext + ); + + [DllImport(NDK_LIBRARY)] + internal static extern int miCASARemoveCredential + ( + [In] uint ssFlags, + [In] SSCS_SECRET_ID_T appSecretID, + [In] SSCS_SECRET_ID_T sharedSecretID, + [In, Out] SSCS_EXT_T ext + ); + + [DllImport(NDK_LIBRARY)] + internal static extern int miCASAIsSecretPersistent + ( + [In] uint ssFlags, + [In] SSCS_SECRET_ID_T secretID, + [In, Out] SSCS_EXT_T ext + ); + + [DllImport(NDK_LIBRARY)] + internal static extern IntPtr miCASAOpenSecretStoreCache + ( + [In, Out] SSCS_SECRET_STORE_ID_T ssid, + uint ssFlags, + [In, Out] SSCS_EXT_T ext + ); + + + [DllImport(NDK_LIBRARY)] + internal static extern int miCASACloseSecretStoreCache + ( + [In] IntPtr context, + [In] uint ssFlags, + [In, Out] SSCS_EXT_T ext + ); + + [DllImport(NDK_LIBRARY, CharSet = CharSet.None)] + internal static extern int miCASAWriteKey + ( + [In] IntPtr context, + [In] uint ssFlags, + [In] SSCS_KEYCHAIN_ID_T keyChainID, + [In] SSCS_SH_SECRET_ID_T sharedSecretID, + [MarshalAs(UnmanagedType.LPStr)] + string key, + [In] uint keyLenBytes, // in bytes + [MarshalAs(UnmanagedType.LPStr)] + string val, + [In] uint valueLenBytes, // in bytes + [In] SSCS_PASSWORD_T password, + [In, Out] SSCS_EXT_T ext + ); + + + /// + /// + /// + /// + /// + + internal static BasicCredential GetCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID, + uint unFlag, + uint credType) + { + if (sAppSecretID == null || sAppSecretID.Length == 0) + throw new MiCasaException(MiCasaException.NSSCS_E_INVALID_PARAM); + + int rcode; + BasicCredential bc = null; + + SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T(); + appSecretID.id = sAppSecretID; + appSecretID.len = sAppSecretID.Length + 1; + + SSCS_SECRET_ID_T sharedID = new SSCS_SECRET_ID_T(); + if (sSharedSecretID != null) + { + sharedID.len = sSharedSecretID.Length + 1; + sharedID.id = sSharedSecretID; + + } + + SSCS_BASIC_CREDENTIAL_UTF8 credential = new SSCS_BASIC_CREDENTIAL_UTF8(); + credential.unFlags = unFlag; + + // alloc some memory + IntPtr pCredential = Marshal.AllocHGlobal(Marshal.SizeOf(credential)); + Marshal.StructureToPtr(credential, pCredential, false); + + try + { + rcode = miCASAGetCredential( + ssFlags, + appSecretID, + sharedID, + ref credType, + pCredential, + new SSCS_EXT_T() + ); + } + catch (Exception) + { + //Console.WriteLine(e.ToString()); + Marshal.FreeHGlobal(pCredential); + throw new MiCasaException(-803); + } + + if (rcode == 0) + { + Marshal.PtrToStructure(pCredential, credential); + string sUsername = GetStringFromUTF8(credential.username, (int)credential.unLen - 1); + string sPassword = GetStringFromUTF8(credential.password, (int)credential.pwordLen - 1); + + bc = new BasicCredential(sUsername, sPassword); + Marshal.FreeHGlobal(pCredential); + return bc; + } + else + { + Marshal.FreeHGlobal(pCredential); + throw new MiCasaException(rcode); + } + + } + + + internal static void SetCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID, + uint unFlag, + uint uCredType, + string sUsername, + string sPassword) + { + + if (sAppSecretID == null || sUsername == null || sPassword == null + || sAppSecretID.Length == 0 || sUsername.Length == 0 || sPassword.Length == 0) + throw new MiCasaException(MiCasaException.NSSCS_E_INVALID_PARAM); + + int rcode; + + SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T(); + appSecretID.id = sAppSecretID; + appSecretID.len = sAppSecretID.Length + 1; + + SSCS_SECRET_ID_T sharedID = new SSCS_SECRET_ID_T(); + if (sSharedSecretID != null) + { + sharedID.len = sSharedSecretID.Length + 1; + sharedID.id = sSharedSecretID; + } + + SSCS_BASIC_CREDENTIAL_UTF8 credential = new SSCS_BASIC_CREDENTIAL_UTF8(); + credential.unFlags = unFlag; + + credential.unLen = GetUTF8ByteCount(sUsername) + 1; + credential.username = GetUTF8FromString(sUsername, USERNAME_LEN); + + credential.pwordLen = GetUTF8ByteCount(sPassword) + 1; + credential.password = GetUTF8FromString(sPassword, PASSWORD_LEN); + + IntPtr pCredential = Marshal.AllocHGlobal(Marshal.SizeOf(credential)); + + Marshal.StructureToPtr(credential, pCredential, true); + + rcode = miCASASetCredential + (ssFlags, + appSecretID, + sharedID, + uCredType, + pCredential, + new SSCS_EXT_T() + ); + + if (rcode != 0) + { + throw new MiCasaException(rcode); + } + } + + + internal static void RemoveCredential( + uint ssFlags, + string sAppSecretID, + string sSharedSecretID) + { + if (sAppSecretID == null || sAppSecretID.Length == 0) + throw new MiCasaException(MiCasaException.NSSCS_E_INVALID_PARAM); + + int rcode; + SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T(); + appSecretID.id = sAppSecretID; + appSecretID.len = sAppSecretID.Length + 1; + + SSCS_SECRET_ID_T sharedID = new SSCS_SECRET_ID_T(); + if (sSharedSecretID != null) + { + sharedID.len = sSharedSecretID.Length + 1; + sharedID.id = sSharedSecretID; + } + + rcode = miCASARemoveCredential(ssFlags, appSecretID, sharedID, new SSCS_EXT_T()); + + if (rcode != 0) + { + throw new MiCasaException(rcode); + } + + } + + + internal static bool IsSecretPersistent(uint ssFlags, string id) + { + int rcode = 0; + + SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T(); + try + { + if (ssFlags == 0) + { + if ((null == id) || ("" == id)) + return false; + + secretID.len = id.Length; + secretID.id = id; + rcode = miCASAIsSecretPersistent(ssFlags, + secretID, + new SSCS_EXT_T()); + } + else + { + rcode = miCASAIsSecretPersistent(ssFlags, + null, + new SSCS_EXT_T()); + } + } + catch (Exception) + { + //Console.WriteLine(e.ToString()); + } + + + if (rcode == 1) + return true; + else + return false; + } + + // helper methods + private static string GetStringFromUTF8(byte[] utf8Bytes, int numBytes) + { + if (numBytes > 0) + { + Decoder utfDec = System.Text.Encoding.UTF8.GetDecoder(); + int charCount = utfDec.GetCharCount(utf8Bytes, 0, numBytes); + char[] chars = new char[charCount]; + int len = utfDec.GetChars(utf8Bytes, 0, numBytes, chars, 0); + + string text = new string(chars); + text = text.Trim(); + return text; + } + else + return ""; + } + + private static uint GetUTF8ByteCount(string str) + { + uint byteCount = (uint)System.Text.Encoding.UTF8.GetEncoder().GetByteCount(str.ToCharArray(), 0, str.Length, true); + return byteCount; + } + + private static byte[] GetUTF8FromString(string str, int arrayLength) + { + // NOTE: Must return a padded array of arrayLength + Encoder utfEnc = System.Text.Encoding.UTF8.GetEncoder(); + byte[] utf8Bytes = new byte[arrayLength]; + int len = utfEnc.GetBytes(str.ToCharArray(), 0, str.Length, utf8Bytes, 0, true); + return utf8Bytes; + } + + + private static string EscapeReservedChars(string origString) + { + if (origString == null) + return 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(); + } + } +} + + diff --git a/CASA/sharp/Novell.Casa.MiCasa/Novell.Casa.MiCasa.csproj b/CASA/sharp/Novell.Casa.MiCasa/Novell.Casa.MiCasa.csproj new file mode 100644 index 00000000..89913995 --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/Novell.Casa.MiCasa.csproj @@ -0,0 +1,53 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {7B56383F-6551-4BCD-81BB-A039BBECBD9C} + Library + Properties + Novell.Casa + Novell.Casa.MiCasa + true + Casa.snk + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CASA/sharp/Novell.Casa.MiCasa/Properties/AssemblyInfo.cs b/CASA/sharp/Novell.Casa.MiCasa/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c20e15bf --- /dev/null +++ b/CASA/sharp/Novell.Casa.MiCasa/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Novell.Casa")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Novell, Inc")] +[assembly: AssemblyProduct("Novell.Casa")] +[assembly: AssemblyCopyright("Copyright © Novell, Inc 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("abc7b4d6-9303-4957-ba67-58249b5aafe0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.7.0.0")] +[assembly: AssemblyFileVersion("1.7.0.0")] diff --git a/CASA/test/c_sharp_sample/cSharpSample.cs b/CASA/test/c_sharp_sample/cSharpSample.cs index 0fc50709..7563000d 100644 --- a/CASA/test/c_sharp_sample/cSharpSample.cs +++ b/CASA/test/c_sharp_sample/cSharpSample.cs @@ -21,7 +21,7 @@ ***********************************************************************/ using System; -using Novell.CASA; +using Novell.Casa; namespace cSharpTest { @@ -43,7 +43,7 @@ namespace cSharpTest static void Main(string[] args) { Console.WriteLine("**************************************************"); - Console.WriteLine("********** miCASA Sample written in C# ***********"); + Console.WriteLine("********** MiCasa Sample written in C# ***********"); Console.WriteLine("**************************************************"); ShowMenu(); } @@ -102,10 +102,10 @@ namespace cSharpTest { try { - //miCASA.SetBasicCredential(sID, null, sUsername, sPassword); - miCASA.SetCredential(0, sID, null, miCASA.USERNAME_TYPE_CN_F, sUsername, sPassword); + //MiCasa.SetBasicCredential(sID, null, sUsername, sPassword); + MiCasa.SetCredential(0, sID, null, MiCasa.USERNAME_TYPE_CN_F, sUsername, sPassword); } - catch (miCasaException e) + catch (MiCasaException e) { Console.WriteLine(e.getMessage()); } @@ -127,9 +127,9 @@ namespace cSharpTest { try { - miCASA.RemoveBasicCredential(sID, null); + MiCasa.RemoveBasicCredential(sID, null); } - catch (miCasaException e) + catch (MiCasaException e) { Console.WriteLine(e.getMessage()); } @@ -145,8 +145,8 @@ namespace cSharpTest try { BasicCredential bc; - //bc = miCASA.GetBasicCredential(sID, null); - bc = miCASA.GetCredential(0, sID, null, miCASA.USERNAME_TYPE_CN_F); + //bc = MiCasa.GetBasicCredential(sID, null); + bc = MiCasa.GetCredential(0, sID, null, MiCasa.USERNAME_TYPE_CN_F); if (bc != null) { Console.WriteLine("Data for "+sID); @@ -162,7 +162,7 @@ namespace cSharpTest else Console.WriteLine(sID + " not found"); } - catch (miCasaException e) + catch (MiCasaException e) { Console.WriteLine(e.getMessage()); } @@ -192,7 +192,7 @@ namespace cSharpTest Console.Write("Setting Credential ....."); try { - miCASA.SetBasicCredential(APPID, null, USERNAME, PASSWORD); + MiCasa.SetBasicCredential(APPID, null, USERNAME, PASSWORD); Console.WriteLine("Succeeded"); } catch (Exception e) @@ -209,7 +209,7 @@ namespace cSharpTest Console.WriteLine("Getting Credential ....."); try { - BasicCredential bc = miCASA.GetBasicCredential(APPID, null); + BasicCredential bc = MiCasa.GetBasicCredential(APPID, null); if (bc != null) { if (bc.GetUsername().Equals(USERNAME)) @@ -230,7 +230,7 @@ namespace cSharpTest try { Console.WriteLine("\r\nRemoving Credential"); - miCASA.RemoveBasicCredential(APPID, null); + MiCasa.RemoveBasicCredential(APPID, null); } catch (Exception e) { @@ -240,7 +240,7 @@ namespace cSharpTest try { - BasicCredential bc = miCASA.GetBasicCredential(APPID, null); + BasicCredential bc = MiCasa.GetBasicCredential(APPID, null); if (bc != null) { Console.WriteLine("\r\nCredential exists and should not - FAILED!"); diff --git a/CASA/test/c_sharp_sample/cSharpSample.csproj b/CASA/test/c_sharp_sample/cSharpSample.csproj index 34f18281..a03d6562 100644 --- a/CASA/test/c_sharp_sample/cSharpSample.csproj +++ b/CASA/test/c_sharp_sample/cSharpSample.csproj @@ -82,11 +82,6 @@ System.XML - - Novell.CASA.miCASAWrapper - {E21DD887-22F4-4935-9851-409715F663B0} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - @@ -97,6 +92,12 @@ Code + + + {7B56383F-6551-4BCD-81BB-A039BBECBD9C} + Novell.Casa.MiCasa + +