summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
index 999fe8d..a313519 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
@@ -27,7 +27,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// The factory method that may be used in deserialization of this message.
/// </summary>
internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
- if ((typeUri == Constants.sreg_ns || Array.IndexOf(Constants.AdditionalTypeUris, typeUri) >= 0) && !isProviderRole) {
+ if ((typeUri == Constants.TypeUris.Standard || Array.IndexOf(Constants.AdditionalTypeUris, typeUri) >= 0) && !isProviderRole) {
return new ClaimsResponse(typeUri);
}
@@ -55,10 +55,11 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
private CultureInfo culture;
/// <summary>
- /// Initializes a new instance of the <see cref="ClaimsResponse"/> class.
+ /// Initializes a new instance of the <see cref="ClaimsResponse"/> class
+ /// using the most common, and spec prescribed type URI.
/// </summary>
- internal ClaimsResponse()
- : this(Constants.sreg_ns) {
+ public ClaimsResponse()
+ : this(Constants.TypeUris.Standard) {
}
/// <summary>
@@ -67,8 +68,10 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// <param name="typeUriToUse">
/// The type URI that must be used to identify this extension in the response message.
/// This value should be the same one the relying party used to send the extension request.
+ /// Commonly used type URIs supported by relying parties are defined in the
+ /// <see cref="Constants.TypeUris"/> class.
/// </param>
- internal ClaimsResponse(string typeUriToUse)
+ public ClaimsResponse(string typeUriToUse = Constants.TypeUris.Standard)
: base(new Version(1, 0), typeUriToUse, Constants.AdditionalTypeUris) {
Requires.NotNullOrEmpty(typeUriToUse, "typeUriToUse");
}
@@ -189,7 +192,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
}
/// <summary>
- /// Gets or sets a combination o the language and country of the user.
+ /// Gets or sets a combination of the language and country of the user.
/// </summary>
[XmlIgnore]
public CultureInfo Culture {
@@ -200,7 +203,16 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
if (!string.IsNullOrEmpty(this.Country)) {
cultureString += "-" + this.Country;
}
- this.culture = CultureInfo.GetCultureInfo(cultureString);
+
+ // language-country may not always form a recongized valid culture.
+ // For instance, a Google OpenID Provider can return a random combination
+ // of language and country based on user settings.
+ try {
+ this.culture = CultureInfo.GetCultureInfo(cultureString);
+ } catch (ArgumentException) { // CultureNotFoundException derives from this, and .NET 3.5 throws the base type
+ // Fallback to just reporting a culture based on language.
+ this.culture = CultureInfo.GetCultureInfo(this.Language);
+ }
}
return this.culture;