diff --git a/c_sharp/NSSCSWrapper/NativeCalls.cs b/c_sharp/NSSCSWrapper/NativeCalls.cs index e720a508..3a977eba 100644 --- a/c_sharp/NSSCSWrapper/NativeCalls.cs +++ b/c_sharp/NSSCSWrapper/NativeCalls.cs @@ -487,6 +487,12 @@ namespace Novell.CASA } } + internal void closeSecretStore(IntPtr hSC) + { + SSCS_EXT_T ext = new SSCS_EXT_T(); + miCASACloseSecretStoreCache(hSC, 0, ext); + } + internal Secret getSecret( IntPtr pHsc, string sKeyChainID, @@ -1228,9 +1234,9 @@ namespace Novell.CASA null, new SSCS_EXT_T()); } - catch(Exception) + catch(Exception e) { - //Console.WriteLine(e.ToString()); + Console.WriteLine(e.ToString()); } return rcode; } @@ -1241,19 +1247,26 @@ namespace Novell.CASA if (null != id && "" !=id) { SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T(); - if(ssFlags == 0) + try { - secretID.len = id.Length; - secretID.id = id; - rcode = miCASAIsSecretPersistent(ssFlags, - secretID, - new SSCS_EXT_T()); + if(ssFlags == 0) + { + secretID.len = id.Length; + secretID.id = id; + rcode = miCASAIsSecretPersistent(ssFlags, + secretID, + new SSCS_EXT_T()); + } + else + { + rcode = miCASAIsSecretPersistent(ssFlags, + null, + new SSCS_EXT_T()); + } } - else + catch (Exception e) { - rcode = miCASAIsSecretPersistent(ssFlags, - null, - new SSCS_EXT_T()); + Console.WriteLine(e.ToString()); } } @@ -1419,6 +1432,19 @@ namespace Novell.CASA } return sb.ToString(); } + + internal static bool ResetMasterPassword(string sCurrentPassword, string sNewPassword) + { + ResetMasterPassword rmp = new ResetMasterPassword(sCurrentPassword, sNewPassword); + ResetMasterPassword o = (ResetMasterPassword)MiCasa.Communication.MiCasaRequestReply.Send( + MiCasaRequestReply.VERB_RESET_MASTER_PASSWORD, + rmp); + + if (o.rcode != 0) + return false; + else + return true; + } } } diff --git a/c_sharp/NSSCSWrapper/SecretStore.cs b/c_sharp/NSSCSWrapper/SecretStore.cs index c44d9f24..777a5b79 100644 --- a/c_sharp/NSSCSWrapper/SecretStore.cs +++ b/c_sharp/NSSCSWrapper/SecretStore.cs @@ -30,42 +30,23 @@ namespace Novell.CASA public static SecretStore getInstance() { - SecretStore newSS = new SecretStore(); - - // Test code for new APIS - /* - miCASA.SetCredential(0, "MyTestApp", null, 0, "MyTestAPPName", "MyTestAPPPassword"); - BasicCredential bc = miCASA.GetCredential(0, "MyTestApp", "Network", 0); - if (bc != null) - { - Console.WriteLine("------"); - Console.WriteLine("Username = " + bc.GetUsername()); - Console.WriteLine("Password = " + bc.GetPassword()); - Console.WriteLine("------"); - } - - - miCASA.RemoveCredential(0, "MyTestApp", null); - - try - { - miCASA.RemoveCredential(0, "MyTestApp", null); - } - catch (Exception e) - { - Console.WriteLine("ClearCredential returned " + e.ToString()); - } - */ - // end test code - + SecretStore newSS = new SecretStore(); return newSS; } + public void ReleaseInstance() + { + if (m_hsc != IntPtr.Zero) + m_NativeCalls.closeSecretStore(m_hsc); + } + + /* public static void ReleaseInstance() { // TODO: } + */ internal Secret getSecret(string sKeyChainID, uint ssFlags, string sSecretID, int iSecretType, string sEPPassword) diff --git a/c_sharp/NSSCSWrapper/miCASA.cs b/c_sharp/NSSCSWrapper/miCASA.cs index 3cb3e60b..18c06e62 100644 --- a/c_sharp/NSSCSWrapper/miCASA.cs +++ b/c_sharp/NSSCSWrapper/miCASA.cs @@ -115,6 +115,19 @@ namespace Novell.CASA { return NativeCalls.IsSecretPersistent(ssFlags,secretID); } - + + public static bool ChangeMasterPassword(string sCurrentPassword, string sNewPassword) + { + if (sCurrentPassword == null || sNewPassword == null) + { + throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM); + } + + if (sNewPassword.Length < 8) + throw new miCasaException(miCasaException.NSSCS_E_MP_PWORD_NOT_ALLOWED); + + return NativeCalls.ResetMasterPassword(sCurrentPassword, sNewPassword); + + } } }