Code for Change Master Password

This commit is contained in:
Jim Norman 2005-11-03 20:24:36 +00:00
parent fb5296c0c3
commit 04e1ae02b0
3 changed files with 61 additions and 41 deletions

View File

@ -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;
}
}
}

View File

@ -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)

View File

@ -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);
}
}
}