public void SetKeySources(IOConnectionInfo iocDb, CompositeKey cmpKey)
{
string strID = GetKeyAssocID(iocDb);
int idx = GetKeyAssocIndex(strID);
if((cmpKey == null) || !m_bRememberKeySources)
{
if(idx >= 0) m_vKeySources.RemoveAt(idx);
return;
}
AceKeyAssoc a = new AceKeyAssoc();
a.DatabasePath = strID;
IUserKey kcpFile = cmpKey.GetUserKey(typeof(KcpKeyFile));
if(kcpFile != null)
{
string strKeyFile = ((KcpKeyFile)kcpFile).Path;
if(!string.IsNullOrEmpty(strKeyFile) && !StrUtil.IsDataUri(strKeyFile))
{
if(!UrlUtil.IsAbsolutePath(strKeyFile))
strKeyFile = UrlUtil.MakeAbsolutePath(WinUtil.GetExecutable(),
strKeyFile);
a.KeyFilePath = strKeyFile;
}
}
IUserKey kcpCustom = cmpKey.GetUserKey(typeof(KcpCustomKey));
if(kcpCustom != null)
a.KeyProvider = ((KcpCustomKey)kcpCustom).Name;
IUserKey kcpUser = cmpKey.GetUserKey(typeof(KcpUserAccount));
a.UserAccount = (kcpUser != null);
bool bAtLeastOne = ((a.KeyFilePath.Length > 0) ||
(a.KeyProvider.Length > 0) || a.UserAccount);
if(bAtLeastOne)
{
if(idx >= 0) m_vKeySources[idx] = a;
else m_vKeySources.Add(a);
}
else if(idx >= 0) m_vKeySources.RemoveAt(idx);
}