public bool ImportPrivateKey(string label, PrivateKeyNotWallet key) { var aliased = AliasManager.SetAlias(label, key); var address = key.Address.Encoded; if (wallets.ContainsKey(label)) { return(false); } wallets.Add(address, aliased); AddressListener.Listen(key.Address); return(true); }
/// <summary> /// Looks at the incoming fields and figures out what the aliases and name spaces for auth level types are. /// </summary> /// <param name="fields">The incoming message data in which to discover TypeURIs and aliases.</param> /// <returns>The <see cref="AliasManager"/> initialized with the given data.</returns> internal static AliasManager FindIncomingAliases(IDictionary<string, string> fields) { AliasManager aliasManager = new AliasManager(); foreach (var pair in fields) { if (!pair.Key.StartsWith(Constants.AuthLevelNamespaceDeclarationPrefix, StringComparison.Ordinal)) { continue; } string alias = pair.Key.Substring(Constants.AuthLevelNamespaceDeclarationPrefix.Length); aliasManager.SetAlias(alias, pair.Value); } aliasManager.SetPreferredAliasesWhereNotSet(Constants.AssuranceLevels.PreferredTypeUriToAliasMap); return aliasManager; }
/// <summary> /// Looks at the incoming fields and figures out what the aliases and name spaces for auth level types are. /// </summary> /// <param name="fields">The incoming message data in which to discover TypeURIs and aliases.</param> /// <returns>The <see cref="AliasManager"/> initialized with the given data.</returns> internal static AliasManager FindIncomingAliases(IDictionary<string, string> fields) { AliasManager aliasManager = new AliasManager(); foreach (var pair in fields) { if (!pair.Key.StartsWith(Constants.AuthLevelNamespaceDeclarationPrefix, StringComparison.Ordinal)) { continue; } string alias = pair.Key.Substring(Constants.AuthLevelNamespaceDeclarationPrefix.Length); aliasManager.SetAlias(alias, pair.Value); } aliasManager.SetPreferredAliasesWhereNotSet(Constants.AssuranceLevels.PreferredTypeUriToAliasMap); return aliasManager; }
static AliasManager parseAliases(IDictionary <string, string> fields) { Debug.Assert(fields != null); AliasManager aliasManager = new AliasManager(); foreach (var pair in fields) { if (!pair.Key.StartsWith("type.", StringComparison.Ordinal)) { continue; } string alias = pair.Key.Substring(5); if (alias.IndexOfAny(new[] { '.', ',', ':' }) >= 0) { Logger.ErrorFormat("Illegal characters in alias name '{0}'.", alias); continue; } aliasManager.SetAlias(alias, pair.Value); } return(aliasManager); }
/// <summary> /// Reads through the attributes included in the response to discover /// the alias-TypeURI relationships. /// </summary> /// <param name="fields">The data included in the extension message.</param> /// <returns>The alias manager that provides lookup between aliases and type URIs.</returns> private static AliasManager ParseAliases(IDictionary <string, string> fields) { Contract.Requires <ArgumentNullException>(fields != null); AliasManager aliasManager = new AliasManager(); const string TypePrefix = "type."; foreach (var pair in fields) { if (!pair.Key.StartsWith(TypePrefix, StringComparison.Ordinal)) { continue; } string alias = pair.Key.Substring(TypePrefix.Length); if (alias.IndexOfAny(FetchRequest.IllegalAliasCharacters) >= 0) { Logger.OpenId.ErrorFormat("Illegal characters in alias name '{0}'.", alias); continue; } aliasManager.SetAlias(alias, pair.Value); } return(aliasManager); }
public bool ImportDeclaration(string alias, TxDeclaration declaration) { AliasManager.SetAlias(alias, declaration); if (declarations.ContainsKey(alias)) { return(false); } declarations.Add(alias, declaration); if (declaration is TxAddressDeclaration) { var address = ((TxAddressDeclaration)declaration).Address; AliasManager.SetAlias(address.Encoded, declaration); if (declarations.ContainsKey(address.Encoded)) { return(false); } declarations.Add(address.Encoded, declaration); AddressListener.Listen(address); } return(true); }
/// <summary> /// Reads through the attributes included in the response to discover /// the alias-TypeURI relationships. /// </summary> /// <param name="fields">The data included in the extension message.</param> /// <returns>The alias manager that provides lookup between aliases and type URIs.</returns> private static AliasManager ParseAliases(IDictionary<string, string> fields) { Contract.Requires<ArgumentNullException>(fields != null); AliasManager aliasManager = new AliasManager(); const string TypePrefix = "type."; foreach (var pair in fields) { if (!pair.Key.StartsWith(TypePrefix, StringComparison.Ordinal)) { continue; } string alias = pair.Key.Substring(TypePrefix.Length); if (alias.IndexOfAny(FetchRequest.IllegalAliasCharacters) >= 0) { Logger.OpenId.ErrorFormat("Illegal characters in alias name '{0}'.", alias); continue; } aliasManager.SetAlias(alias, pair.Value); } return aliasManager; }
bool IExtensionRequest.Deserialize(IDictionary <string, string> fields, DotNetOpenId.Provider.IRequest request, string typeUri) { if (fields == null) { return(false); } string mode; fields.TryGetValue("mode", out mode); if (mode != Mode) { return(false); } string updateUrl; fields.TryGetValue("update_url", out updateUrl); Uri updateUri; if (Uri.TryCreate(updateUrl, UriKind.Absolute, out updateUri)) { UpdateUrl = updateUri; } string requiredAliasString, optionalAliasString; fields.TryGetValue("if_available", out optionalAliasString); fields.TryGetValue("required", out requiredAliasString); var requiredAliases = parseAliasList(requiredAliasString); var optionalAliases = parseAliasList(optionalAliasString); // if an alias shows up in both lists, an exception will result implicitly. var allAliases = new List <string>(requiredAliases.Count + optionalAliases.Count); allAliases.AddRange(requiredAliases); allAliases.AddRange(optionalAliases); if (allAliases.Count == 0) { Logger.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); return(false); } AliasManager aliasManager = new AliasManager(); foreach (var alias in allAliases) { string attributeTypeUri; if (fields.TryGetValue("type." + alias, out attributeTypeUri)) { aliasManager.SetAlias(alias, attributeTypeUri); AttributeRequest att = new AttributeRequest { TypeUri = attributeTypeUri, IsRequired = requiredAliases.Contains(alias), }; string countString; if (fields.TryGetValue("count." + alias, out countString)) { if (countString == "unlimited") { att.Count = int.MaxValue; } else { int count; if (int.TryParse(countString, out count) && count > 0) { att.Count = count; } else { Logger.Error("count." + alias + " could not be parsed into a positive integer."); } } } else { att.Count = 1; } AddAttribute(att); } else { Logger.Error("Type URI definition of alias " + alias + " is missing."); } } return(true); }
/// <summary> /// Called when the message has been received, /// after it passes through the channel binding elements. /// </summary> void IMessageWithEvents.OnReceiving() { var extraData = ((IMessage)this).ExtraData; var requiredAliases = ParseAliasList(this.RequiredAliases); var optionalAliases = ParseAliasList(this.OptionalAliases); // if an alias shows up in both lists, an exception will result implicitly. var allAliases = new List<string>(requiredAliases.Count + optionalAliases.Count); allAliases.AddRange(requiredAliases); allAliases.AddRange(optionalAliases); if (allAliases.Count == 0) { Logger.OpenId.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); return; } AliasManager aliasManager = new AliasManager(); foreach (var alias in allAliases) { string attributeTypeUri; if (extraData.TryGetValue("type." + alias, out attributeTypeUri)) { aliasManager.SetAlias(alias, attributeTypeUri); AttributeRequest att = new AttributeRequest { TypeUri = attributeTypeUri, IsRequired = requiredAliases.Contains(alias), }; string countString; if (extraData.TryGetValue("count." + alias, out countString)) { if (countString == "unlimited") { att.Count = int.MaxValue; } else { int count; if (int.TryParse(countString, out count) && count > 0) { att.Count = count; } else { Logger.OpenId.Error("count." + alias + " could not be parsed into a positive integer."); } } } else { att.Count = 1; } this.Attributes.Add(att); } else { Logger.OpenId.Error("Type URI definition of alias " + alias + " is missing."); } } }
bool IExtensionRequest.Deserialize(IDictionary<string, string> fields, DotNetOpenId.Provider.IRequest request, string typeUri) { if (fields == null) return false; string mode; fields.TryGetValue("mode", out mode); if (mode != Mode) return false; string updateUrl; fields.TryGetValue("update_url", out updateUrl); Uri updateUri; if (Uri.TryCreate(updateUrl, UriKind.Absolute, out updateUri)) UpdateUrl = updateUri; string requiredAliasString, optionalAliasString; fields.TryGetValue("if_available", out optionalAliasString); fields.TryGetValue("required", out requiredAliasString); var requiredAliases = parseAliasList(requiredAliasString); var optionalAliases = parseAliasList(optionalAliasString); // if an alias shows up in both lists, an exception will result implicitly. var allAliases = new List<string>(requiredAliases.Count + optionalAliases.Count); allAliases.AddRange(requiredAliases); allAliases.AddRange(optionalAliases); if (allAliases.Count == 0) { Logger.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); return false; } AliasManager aliasManager = new AliasManager(); foreach (var alias in allAliases) { string attributeTypeUri; if (fields.TryGetValue("type." + alias, out attributeTypeUri)) { aliasManager.SetAlias(alias, attributeTypeUri); AttributeRequest att = new AttributeRequest { TypeUri = attributeTypeUri, IsRequired = requiredAliases.Contains(alias), }; string countString; if (fields.TryGetValue("count." + alias, out countString)) { if (countString == "unlimited") att.Count = int.MaxValue; else { int count; if (int.TryParse(countString, out count) && count > 0) { att.Count = count; } else { Logger.Error("count." + alias + " could not be parsed into a positive integer."); } } } else { att.Count = 1; } AddAttribute(att); } else { Logger.Error("Type URI definition of alias " + alias + " is missing."); } } return true; }
/// <summary> /// Called when the message has been received, /// after it passes through the channel binding elements. /// </summary> void IMessageWithEvents.OnReceiving() { var extraData = ((IMessage)this).ExtraData; var requiredAliases = ParseAliasList(this.RequiredAliases); var optionalAliases = ParseAliasList(this.OptionalAliases); // if an alias shows up in both lists, an exception will result implicitly. var allAliases = new List <string>(requiredAliases.Count + optionalAliases.Count); allAliases.AddRange(requiredAliases); allAliases.AddRange(optionalAliases); if (allAliases.Count == 0) { Logger.OpenId.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); return; } AliasManager aliasManager = new AliasManager(); foreach (var alias in allAliases) { string attributeTypeUri; if (extraData.TryGetValue("type." + alias, out attributeTypeUri)) { aliasManager.SetAlias(alias, attributeTypeUri); AttributeRequest att = new AttributeRequest { TypeUri = attributeTypeUri, IsRequired = requiredAliases.Contains(alias), }; string countString; if (extraData.TryGetValue("count." + alias, out countString)) { if (countString == "unlimited") { att.Count = int.MaxValue; } else { int count; if (int.TryParse(countString, out count) && count > 0) { att.Count = count; } else { Logger.OpenId.Error("count." + alias + " could not be parsed into a positive integer."); } } } else { att.Count = 1; } this.Attributes.Add(att); } else { Logger.OpenId.Error("Type URI definition of alias " + alias + " is missing."); } } }
static AliasManager parseAliases(IDictionary<string, string> fields) { Debug.Assert(fields != null); AliasManager aliasManager = new AliasManager(); foreach (var pair in fields) { if (!pair.Key.StartsWith("type.", StringComparison.Ordinal)) continue; string alias = pair.Key.Substring(5); if (alias.IndexOfAny(new[] { '.', ',', ':' }) >= 0) { Logger.ErrorFormat("Illegal characters in alias name '{0}'.", alias); continue; } aliasManager.SetAlias(alias, pair.Value); } return aliasManager; }