summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-03-25 21:44:02 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-03-25 21:44:02 -0700
commit5477da58070c3dd4b4a7d9d18df085c26d3b8ae6 (patch)
tree844f9ee10ace987480208f7266987c7de6388e6b
parentac200ebac84ce798a16f580a2145c7160b0e29a8 (diff)
downloadDotNetOpenAuth-5477da58070c3dd4b4a7d9d18df085c26d3b8ae6.zip
DotNetOpenAuth-5477da58070c3dd4b4a7d9d18df085c26d3b8ae6.tar.gz
DotNetOpenAuth-5477da58070c3dd4b4a7d9d18df085c26d3b8ae6.tar.bz2
Catches XmlExceptions thrown while processing tokens and fire the appropriate event.
-rw-r--r--samples/InfoCardRelyingParty/Login.aspx7
-rw-r--r--src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs26
2 files changed, 22 insertions, 11 deletions
diff --git a/samples/InfoCardRelyingParty/Login.aspx b/samples/InfoCardRelyingParty/Login.aspx
index 476a15c..dfb7499 100644
--- a/samples/InfoCardRelyingParty/Login.aspx
+++ b/samples/InfoCardRelyingParty/Login.aspx
@@ -1,5 +1,6 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
ValidateRequest="false" %>
+
<%@ Import Namespace="DotNetOpenAuth.InfoCard" %>
<script runat="server">
@@ -7,6 +8,11 @@
Session("SiteSpecificID") = e.Token.SiteSpecificId
FormsAuthentication.RedirectFromLoginPage(e.Token.UniqueId, False)
End Sub
+
+ Protected Sub InfoCardSelector1_TokenProcessingError(ByVal sender As Object, ByVal e As TokenProcessingErrorEventArgs) Handles InfoCardSelector1.TokenProcessingError
+ errorLabel.Text = HttpUtility.HtmlEncode(e.Exception.Message)
+ errorLabel.Visible = True
+ End Sub
</script>
<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.InfoCard" TagPrefix="ic" %>
@@ -24,4 +30,5 @@
a link to find out how to enable the user's browser to use InfoCards. </p>
</UnsupportedTemplate>
</ic:InfoCardSelector>
+ <asp:Label runat="server" EnableViewState="false" Visible="false" ForeColor="Red" ID="errorLabel" />
</asp:Content>
diff --git a/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs b/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs
index aa02ebe..3ca8e88 100644
--- a/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs
+++ b/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs
@@ -18,6 +18,7 @@ namespace DotNetOpenAuth.InfoCard {
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
+ using System.Xml;
using DotNetOpenAuth.Messaging;
/// <summary>
@@ -376,18 +377,21 @@ namespace DotNetOpenAuth.InfoCard {
/// <param name="eventArgument">A <see cref="T:System.String"/> that represents an optional event argument to be passed to the event handler.</param>
public void RaisePostBackEvent(string eventArgument) {
if (!string.IsNullOrEmpty(this.TokenXml)) {
- bool encrypted = Token.IsEncrypted(this.TokenXml);
- TokenDecryptor decryptor = encrypted ? new TokenDecryptor() : null;
- ReceivingTokenEventArgs receivingArgs = this.OnReceivingToken(this.TokenXml, decryptor);
-
- if (!receivingArgs.Cancel) {
- try {
- Token token = new Token(this.TokenXml, this.Audience, decryptor);
- this.OnReceivedToken(token);
- } catch (InformationCardException ex) {
- this.OnTokenProcessingError(this.TokenXml, ex);
- return;
+ try {
+ bool encrypted = Token.IsEncrypted(this.TokenXml);
+ TokenDecryptor decryptor = encrypted ? new TokenDecryptor() : null;
+ ReceivingTokenEventArgs receivingArgs = this.OnReceivingToken(this.TokenXml, decryptor);
+
+ if (!receivingArgs.Cancel) {
+ try {
+ Token token = new Token(this.TokenXml, this.Audience, decryptor);
+ this.OnReceivedToken(token);
+ } catch (InformationCardException ex) {
+ this.OnTokenProcessingError(this.TokenXml, ex);
+ }
}
+ } catch (XmlException ex) {
+ this.OnTokenProcessingError(this.TokenXml, ex);
}
}
}