int SecretKeyStore::deleteAllSecretKeys(bool fSuspend, bool fForce) { /* First check whether a key is still in use. */ if (!fForce) { for (SecretKeyMap::iterator it = m_mapSecretKeys.begin(); it != m_mapSecretKeys.end(); it++) { SecretKey *pKey = it->second; if ( pKey->refCount() && ( ( pKey->getRemoveOnSuspend() && fSuspend) || !fSuspend)) return VERR_RESOURCE_IN_USE; } } SecretKeyMap::iterator it = m_mapSecretKeys.begin(); while (it != m_mapSecretKeys.end()) { SecretKey *pKey = it->second; if ( pKey->getRemoveOnSuspend() || !fSuspend) { AssertMsg(!pKey->refCount(), ("No one should access the stored key at this point anymore!\n")); delete pKey; m_mapSecretKeys.erase(it++); } else it++; } return VINF_SUCCESS; }
int SecretKeyStore::deleteSecretKey(const com::Utf8Str &strKeyId) { SecretKeyMap::iterator it = m_mapSecretKeys.find(strKeyId); if (it == m_mapSecretKeys.end()) return VERR_NOT_FOUND; SecretKey *pKey = it->second; if (pKey->refCount() != 0) return VERR_RESOURCE_IN_USE; m_mapSecretKeys.erase(it); delete pKey; return VINF_SUCCESS; }