Bug 130518. Throw INVALID PARAMETER exception on null and empty strings

This commit is contained in:
Jim Norman 2005-10-31 20:26:21 +00:00
parent 4df26f8574
commit 16eff73590
3 changed files with 389 additions and 329 deletions

View File

@ -465,6 +465,12 @@ namespace Novell.CASA
// Methods start here // Methods start here
internal IntPtr openSecretStore(string sSecretStoreName) 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(); SSCS_SECRET_STORE_ID_T SSid = new SSCS_SECRET_STORE_ID_T();
SSid.id = sSecretStoreName; SSid.id = sSecretStoreName;
SSid.len = sSecretStoreName.Length; SSid.len = sSecretStoreName.Length;
@ -488,8 +494,12 @@ namespace Novell.CASA
string sSharedSecretID, string sSharedSecretID,
int iSecretType, int iSecretType,
string sEPPassword) 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 // setup structures
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T(); SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
keyChainID.keychainID = sKeyChainID; keyChainID.keychainID = sKeyChainID;
@ -720,7 +730,7 @@ namespace Novell.CASA
return true; return true;
} }
} }
Console.WriteLine("key = " + key + " is not present in nvc"); //Console.WriteLine("key = " + key + " is not present in nvc");
return false; return false;
} }
@ -734,6 +744,8 @@ namespace Novell.CASA
{ {
int rcode = 0; int rcode = 0;
if (sKeyChainID == null || sKeyChainID.Length == 0)
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
// now call miCASAWriteSecret // now call miCASAWriteSecret
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T(); SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
@ -862,6 +874,11 @@ namespace Novell.CASA
string sSecretID, string sSecretID,
int iSecretType) 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; int rcode = 0;
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T(); 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 // setup structures
SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T(); SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
keyChainID.keychainID = sKeyChainID; keyChainID.keychainID = sKeyChainID;
@ -969,6 +991,10 @@ namespace Novell.CASA
uint ssFlags, uint ssFlags,
string sKeyChainID) 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(); SSCS_KEYCHAIN_ID_T keyChainID = new SSCS_KEYCHAIN_ID_T();
keyChainID.keychainID = sKeyChainID; keyChainID.keychainID = sKeyChainID;
keyChainID.len = sKeyChainID.Length + 1; keyChainID.len = sKeyChainID.Length + 1;
@ -985,6 +1011,9 @@ namespace Novell.CASA
uint unFlag) uint unFlag)
{ {
if (sAppSecretID==null || sAppSecretID.Length == 0)
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
int rcode; int rcode;
BasicCredential bc = null; BasicCredential bc = null;
@ -1044,6 +1073,11 @@ namespace Novell.CASA
string sUsername, string sUsername,
string sPassword) 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; int rcode;
SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T(); SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T();
@ -1092,6 +1126,9 @@ namespace Novell.CASA
string sSharedSecretID) string sSharedSecretID)
{ {
if (sAppSecretID == null || sAppSecretID.Length==0)
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
int rcode; int rcode;
SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T(); SSCS_SECRET_ID_T appSecretID = new SSCS_SECRET_ID_T();
appSecretID.id = sAppSecretID; appSecretID.id = sAppSecretID;
@ -1113,10 +1150,14 @@ namespace Novell.CASA
} }
public static int SetMasterPasscode( internal static int SetMasterPasscode(
uint ssFlags, uint ssFlags,
string passcodeStr) string passcodeStr)
{ {
if (passcodeStr==null || passcodeStr.Length==0)
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
int rcode = -1; int rcode = -1;
try try
{ {
@ -1151,6 +1192,10 @@ namespace Novell.CASA
uint ssFlags, uint ssFlags,
string mPasswd) string mPasswd)
{ {
if (mPasswd==null || mPasswd.Length==0)
return 1;
int rcode = -1; int rcode = -1;
try try
{ {
@ -1166,7 +1211,7 @@ namespace Novell.CASA
null, null,
new SSCS_EXT_T()); new SSCS_EXT_T());
} }
catch(Exception e) catch(Exception)
{ {
//Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
} }
@ -1175,7 +1220,9 @@ namespace Novell.CASA
public static bool IsSecretPersistent(uint ssFlags, string id) 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(); SSCS_SECRET_ID_T secretID = new SSCS_SECRET_ID_T();
if(ssFlags == 0) if(ssFlags == 0)
{ {
@ -1191,6 +1238,8 @@ namespace Novell.CASA
null, null,
new SSCS_EXT_T()); new SSCS_EXT_T());
} }
}
if(rcode == 1) if(rcode == 1)
return true; return true;
else else
@ -1234,6 +1283,9 @@ namespace Novell.CASA
string secretID, string secretID,
string keyID) 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; int rcode = 0;
@ -1257,6 +1309,10 @@ namespace Novell.CASA
string sKeyChainID, string sKeyChainID,
string secretID) string secretID)
{ {
if (sKeyChainID==null || secretID==null
|| sKeyChainID.Length==0 || secretID.Length==0)
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
ArrayList keyList = null; ArrayList keyList = null;
try try
{ {
@ -1291,6 +1347,9 @@ namespace Novell.CASA
string secretID, string secretID,
string keyID) 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; int rcode = 0;
string value = null; string value = null;
@ -1314,6 +1373,9 @@ namespace Novell.CASA
private string EscapeReservedChars(string origString) private string EscapeReservedChars(string origString)
{ {
if (origString==null)
return origString;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i=0; i<origString.Length; i++) for (int i=0; i<origString.Length; i++)
{ {

View File

@ -58,7 +58,6 @@ namespace Novell.CASA
} }
public static BasicCredential GetBasicCredential( public static BasicCredential GetBasicCredential(
string sAppSecretID, string sAppSecretID,
string sSharedSecretID) string sSharedSecretID)
@ -102,20 +101,14 @@ namespace Novell.CASA
{ {
NativeCalls.RemoveCredential(ssFlags, sAppSecretID, sSharedSecretID); NativeCalls.RemoveCredential(ssFlags, sAppSecretID, sSharedSecretID);
} }
/*
internal static int SetMasterPasscode(
uint ssFlags,
string passcodeStr)
{
return NativeCalls.SetMasterPasscode(ssFlags,passcodeStr);
}
*/
public static int SetMasterPassword( public static int SetMasterPassword(
uint ssFlags, uint ssFlags,
string mPasswd) string mPasswd)
{ {
return NativeCalls.SetMasterPassword(ssFlags,mPasswd); return NativeCalls.SetMasterPassword(ssFlags,mPasswd);
} }
public static bool IsSecretPersistent( public static bool IsSecretPersistent(
uint ssFlags, uint ssFlags,
string secretID) string secretID)

View File

@ -319,6 +319,11 @@ namespace Novell.CASA
return getMessage(m_iException); return getMessage(m_iException);
} }
public int getErrorCode()
{
return m_iException;
}
public string getMessage(int iException) public string getMessage(int iException)
{ {
switch (iException) switch (iException)