summaryrefslogtreecommitdiffstats
path: root/samples/OpenIdProviderWebForms/Default.aspx
blob: a0cb02a212b3756db566a67b47aaa0e30745ee70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>

<%@ Import Namespace="OpenIdProviderWebForms.Code" %>
<%@ Import Namespace="DotNetOpenAuth.OpenId.Provider" %>
<%@ Import Namespace="DotNetOpenAuth.Messaging" %>
<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId" TagPrefix="openid" %>
<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth" TagPrefix="openauth" %>

<script runat="server">
	protected void sendAssertionButton_Click(object sender, EventArgs e) {
		TextBox relyingPartySite = (TextBox)loginView.FindControl("relyingPartySite");
		Uri providerEndpoint = new Uri(Request.Url, Page.ResolveUrl("~/server.aspx"));
		OpenIdProvider op = new OpenIdProvider();
		try {
			op.PrepareUnsolicitedAssertion(providerEndpoint, relyingPartySite.Text, Util.BuildIdentityUrl(), Util.BuildIdentityUrl()).Send();
		} catch (ProtocolException ex) {
			Label errorLabel = (Label)loginView.FindControl("errorLabel");
			errorLabel.Visible = true;
			errorLabel.Text = ex.Message;
		}
	}
</script>

<asp:Content runat="server" ContentPlaceHolderID="head">
	<openauth:XrdsPublisher runat="server" XrdsUrl="~/op_xrds.aspx" />
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="Main">
	<h2>Provider </h2>
	<p>Welcome. This site doesn't do anything more than simple authentication of users.
		Start the authentication process on the Relying Party sample site, or log in here
		and send an unsolicited assertion. </p>
	<asp:LoginView runat="server" ID="loginView">
		<LoggedInTemplate>
			<asp:Panel runat="server" DefaultButton="sendAssertionButton">
				Since you're logged in, try sending an unsolicited assertion to an OpenID 2.0 relying
				party site. Just type in the URL to the site's home page. This could be the sample
				relying party web site.
				<br />
				<asp:TextBox runat="server" ID="relyingPartySite" Columns="40" />
				<asp:Button runat="server" ID="sendAssertionButton" Text="Send assertion" OnClick="sendAssertionButton_Click" />
				<asp:RequiredFieldValidator runat="server" ControlToValidate="relyingPartySite" Text="Specify relying party site first" />
				<br />
				An unsolicited assertion is a way to log in to a relying party site directly from
				your OpenID Provider.
				<p>
					<asp:Label runat="server" EnableViewState="false" Visible="false" ID="errorLabel"
						ForeColor="Red" />
				</p>
			</asp:Panel>
		</LoggedInTemplate>
	</asp:LoginView>
	<asp:LoginStatus runat="server" />
</asp:Content>