Code for Change Master Password
This commit is contained in:
parent
fb5296c0c3
commit
04e1ae02b0
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user