Bug 130518. Throw INVALID PARAMETER exception on null and empty strings
This commit is contained in:
parent
4df26f8574
commit
16eff73590
@ -465,6 +465,12 @@ namespace Novell.CASA
|
||||
// Methods start here
|
||||
internal IntPtr openSecretStore(string sSecretStoreName)
|
||||
{
|
||||
|
||||
//check params
|
||||
if (sSecretStoreName == null || sSecretStoreName.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
|
||||
SSCS_SECRET_STORE_ID_T SSid = new SSCS_SECRET_STORE_ID_T();
|
||||
SSid.id = sSecretStoreName;
|
||||
SSid.len = sSecretStoreName.Length;
|
||||
@ -488,8 +494,12 @@ namespace Novell.CASA
|
||||
string sSharedSecretID,
|
||||
int iSecretType,
|
||||
string sEPPassword)
|
||||
|
||||
{
|
||||
|
||||
if (pHsc == IntPtr.Zero || sKeyChainID == null || sSharedSecretID == null
|
||||
|| sKeyChainID.Length == 0 || sSharedSecretID.Length == 0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
// setup structures
|
||||
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
|
||||
keyChainID.keychainID = sKeyChainID;
|
||||
@ -720,7 +730,7 @@ namespace Novell.CASA
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("key = " + key + " is not present in nvc");
|
||||
//Console.WriteLine("key = " + key + " is not present in nvc");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -734,6 +744,8 @@ namespace Novell.CASA
|
||||
{
|
||||
|
||||
int rcode = 0;
|
||||
if (sKeyChainID == null || sKeyChainID.Length == 0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
// now call miCASAWriteSecret
|
||||
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
|
||||
@ -862,6 +874,11 @@ namespace Novell.CASA
|
||||
string sSecretID,
|
||||
int iSecretType)
|
||||
{
|
||||
|
||||
if (context == IntPtr.Zero || sKeyChainID == null || sSecretID == null
|
||||
|| sKeyChainID.Length==0 || sSecretID.Length==0)
|
||||
return miCasaException.NSSCS_E_INVALID_PARAM;
|
||||
|
||||
int rcode = 0;
|
||||
|
||||
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
|
||||
@ -903,6 +920,11 @@ namespace Novell.CASA
|
||||
{
|
||||
|
||||
|
||||
if (context == IntPtr.Zero || sKeyChainID==null || sSearchKey==null
|
||||
|| sKeyChainID.Length==0)
|
||||
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
// setup structures
|
||||
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
|
||||
keyChainID.keychainID = sKeyChainID;
|
||||
@ -969,6 +991,10 @@ namespace Novell.CASA
|
||||
uint ssFlags,
|
||||
string sKeyChainID)
|
||||
{
|
||||
|
||||
if (context==IntPtr.Zero || sKeyChainID==null || sKeyChainID.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
|
||||
keyChainID.keychainID = sKeyChainID;
|
||||
keyChainID.len = sKeyChainID.Length + 1;
|
||||
@ -985,6 +1011,9 @@ namespace Novell.CASA
|
||||
uint unFlag)
|
||||
|
||||
{
|
||||
if (sAppSecretID==null || sAppSecretID.Length == 0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
int rcode;
|
||||
BasicCredential bc = null;
|
||||
|
||||
@ -1044,6 +1073,11 @@ namespace Novell.CASA
|
||||
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();
|
||||
@ -1092,6 +1126,9 @@ namespace Novell.CASA
|
||||
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;
|
||||
@ -1113,10 +1150,14 @@ namespace Novell.CASA
|
||||
|
||||
}
|
||||
|
||||
public static int SetMasterPasscode(
|
||||
internal static int SetMasterPasscode(
|
||||
uint ssFlags,
|
||||
string passcodeStr)
|
||||
{
|
||||
|
||||
if (passcodeStr==null || passcodeStr.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
int rcode = -1;
|
||||
try
|
||||
{
|
||||
@ -1151,6 +1192,10 @@ namespace Novell.CASA
|
||||
uint ssFlags,
|
||||
string mPasswd)
|
||||
{
|
||||
|
||||
if (mPasswd==null || mPasswd.Length==0)
|
||||
return 1;
|
||||
|
||||
int rcode = -1;
|
||||
try
|
||||
{
|
||||
@ -1166,7 +1211,7 @@ namespace Novell.CASA
|
||||
null,
|
||||
new SSCS_EXT_T());
|
||||
}
|
||||
catch(Exception e)
|
||||
catch(Exception)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
@ -1175,7 +1220,9 @@ namespace Novell.CASA
|
||||
|
||||
public static bool IsSecretPersistent(uint ssFlags, string id)
|
||||
{
|
||||
int rcode;
|
||||
int rcode = 0;
|
||||
if (null != id && "" !=id)
|
||||
{
|
||||
SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T();
|
||||
if(ssFlags == 0)
|
||||
{
|
||||
@ -1191,6 +1238,8 @@ namespace Novell.CASA
|
||||
null,
|
||||
new SSCS_EXT_T());
|
||||
}
|
||||
}
|
||||
|
||||
if(rcode == 1)
|
||||
return true;
|
||||
else
|
||||
@ -1234,6 +1283,9 @@ namespace Novell.CASA
|
||||
string secretID,
|
||||
string keyID)
|
||||
{
|
||||
if (sKeyChainID==null || secretID==null || keyID==null
|
||||
|| sKeyChainID.Length==0 || secretID.Length==0 || keyID.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
int rcode = 0;
|
||||
|
||||
@ -1257,6 +1309,10 @@ namespace Novell.CASA
|
||||
string sKeyChainID,
|
||||
string secretID)
|
||||
{
|
||||
if (sKeyChainID==null || secretID==null
|
||||
|| sKeyChainID.Length==0 || secretID.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
ArrayList keyList = null;
|
||||
try
|
||||
{
|
||||
@ -1291,6 +1347,9 @@ namespace Novell.CASA
|
||||
string secretID,
|
||||
string keyID)
|
||||
{
|
||||
if (sKeyChainID==null || secretID==null || keyID==null
|
||||
|| sKeyChainID.Length==0 || secretID.Length==0 || keyID.Length==0)
|
||||
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
|
||||
|
||||
int rcode = 0;
|
||||
string value = null;
|
||||
@ -1314,6 +1373,9 @@ namespace Novell.CASA
|
||||
|
||||
private string EscapeReservedChars(string origString)
|
||||
{
|
||||
if (origString==null)
|
||||
return origString;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i=0; i<origString.Length; i++)
|
||||
{
|
||||
|
@ -58,7 +58,6 @@ namespace Novell.CASA
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static BasicCredential GetBasicCredential(
|
||||
string sAppSecretID,
|
||||
string sSharedSecretID)
|
||||
@ -102,20 +101,14 @@ namespace Novell.CASA
|
||||
{
|
||||
NativeCalls.RemoveCredential(ssFlags, sAppSecretID, sSharedSecretID);
|
||||
}
|
||||
/*
|
||||
internal static int SetMasterPasscode(
|
||||
uint ssFlags,
|
||||
string passcodeStr)
|
||||
{
|
||||
return NativeCalls.SetMasterPasscode(ssFlags,passcodeStr);
|
||||
}
|
||||
*/
|
||||
|
||||
public static int SetMasterPassword(
|
||||
uint ssFlags,
|
||||
string mPasswd)
|
||||
{
|
||||
return NativeCalls.SetMasterPassword(ssFlags,mPasswd);
|
||||
}
|
||||
|
||||
public static bool IsSecretPersistent(
|
||||
uint ssFlags,
|
||||
string secretID)
|
||||
|
@ -319,6 +319,11 @@ namespace Novell.CASA
|
||||
return getMessage(m_iException);
|
||||
}
|
||||
|
||||
public int getErrorCode()
|
||||
{
|
||||
return m_iException;
|
||||
}
|
||||
|
||||
public string getMessage(int iException)
|
||||
{
|
||||
switch (iException)
|
||||
|
Loading…
Reference in New Issue
Block a user