public IDictionary<string, string> GetAttributes() {
var attributes = new Dictionary<string, string>(StringComparer.Ordinal);
string alias;
var extensions = GetExtensions();
// If the ax alias cannot be found, return an empty dictionary.
if (!extensions.TryGetValue(OpenIdAuthenticationConstants.Namespaces.Ax, out alias)) {
return attributes;
}
foreach (var parameter in Parameters) {
var prefix = $"{OpenIdAuthenticationConstants.Prefixes.OpenId}.{alias}.{OpenIdAuthenticationConstants.Suffixes.Type}.";
// Exclude parameters that don't correspond to the attribute exchange alias.
if (!parameter.Key.StartsWith(prefix, StringComparison.Ordinal)) {
continue;
}
// Exclude attributes whose alias is malformed.
var name = parameter.Key.Substring(prefix.Length);
if (string.IsNullOrEmpty(name)) {
continue;
}
// Exclude attributes whose type is missing.
var type = parameter.Value;
if (string.IsNullOrEmpty(type)) {
continue;
}
// Exclude attributes whose value is missing.
string value;
if (!Parameters.TryGetValue($"{OpenIdAuthenticationConstants.Prefixes.OpenId}.{alias}." +
$"{OpenIdAuthenticationConstants.Suffixes.Value}.{name}", out value)) {
continue;
}
// Exclude attributes whose value is null or empty.
if (string.IsNullOrEmpty(value)) {
continue;
}
attributes.Add(type, value);
}
return attributes;
}