/// <summary> /// Returns password for specified userName and nodeName /// </summary> public static string GetPassword(object sender, string nodeName, string userName) { ErlPasswordSession res = null; var inCache = false; //check cache lock (m_passCache) inCache = m_passCache.TryGetValue(new ErlPasswordSession(nodeName, userName), out res); if (inCache) { if (res.Password == null) { //ask user about password if (PasswordRequired != null) { PasswordRequired(res); } } return(SecureStringToString(res.Password)); } throw new ErlException("Password session is not started"); }
/// <summary> /// Starts cache session of password /// </summary> public static ErlPasswordSession StartPasswordSession(string nodeName, string userName) { var ps = new ErlPasswordSession(nodeName, userName); //cahce contains this node already, so return fake ErlPasswordSession lock (m_passCache) { if (m_passCache.ContainsKey(ps)) return ps; //add to cache m_passCache.Add(ps, ps); } return ps; }
/// <summary> /// Starts cache session of password /// </summary> public static ErlPasswordSession StartPasswordSession(string nodeName, string userName) { var ps = new ErlPasswordSession(nodeName, userName); //cache contains this node already, so return fake ErlPasswordSession lock (s_PassCache) { if (s_PassCache.ContainsKey(ps)) { return(ps); } //add to cache s_PassCache.Add(ps, ps); } return(ps); }
/// <summary> /// Returns password for specified userName and nodeName /// </summary> public static SecureString GetPassword(object sender, string nodeName, string userName) { ErlPasswordSession res = null; var inCache = false; //check cache lock (s_PassCache) inCache = s_PassCache.TryGetValue(new ErlPasswordSession(nodeName, userName), out res); if (inCache) { if (res.Password == null && PasswordRequired != null) //ask user about password { PasswordRequired(res); } if (res.Password != null) { return(res.Password); } } throw new ErlException("Password session not started for {0} user {1}".Args(nodeName, userName)); }
/// <summary> /// Removes password session from cache /// </summary> internal static void FinishPasswordSession(ErlPasswordSession ps) { lock (s_PassCache) s_PassCache.Remove(ps); }
/// <summary> /// Removes password session from cache /// </summary> internal static void FinishPasswordSession(ErlPasswordSession ps) { lock (m_passCache) m_passCache.Remove(ps); }