diff options
-rw-r--r-- | samples/OpenIdOfflineProvider/CheckIdWindow.xaml | 18 | ||||
-rw-r--r-- | samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs | 37 | ||||
-rw-r--r-- | samples/OpenIdOfflineProvider/HostedProvider.cs | 22 | ||||
-rw-r--r-- | samples/OpenIdOfflineProvider/MainWindow.xaml | 30 | ||||
-rw-r--r-- | samples/OpenIdOfflineProvider/MainWindow.xaml.cs | 16 |
5 files changed, 61 insertions, 62 deletions
diff --git a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml index 9ffe919..1211976 100644 --- a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml +++ b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml @@ -4,7 +4,7 @@ Title="Authentication request" Height="345" Width="379"> <DockPanel Margin="12"> <TextBlock DockPanel.Dock="Top" TextWrapping="Wrap">An authentication request has been received. How do you want to proceed?</TextBlock> - <Expander DockPanel.Dock="Top" Header="View request details"> + <Expander DockPanel.Dock="Top" Header="View request details" IsExpanded="True"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto" /> @@ -22,14 +22,14 @@ <Label Grid.Column="1" Name="setupModeLabel" Content="No" /> <Label Grid.Row="1">Realm</Label> <Label Grid.Row="1" Grid.Column="1" Name="realmLabel" /> - <Label Grid.Row="2">Callback</Label> - <Label Grid.Row="2" Grid.Column="1" Name="callbackLabel" /> + <!--<Label Grid.Row="2">Callback</Label> + <Label Grid.Row="2" Grid.Column="1" Name="callbackLabel" />--> <Label Grid.Row="3">Discoverable</Label> <Label Grid.Row="3" Grid.Column="1" Name="discoverableYesLabel" Content="Yes" /> <Label Grid.Row="3" Grid.Column="1" Name="discoverableNoLabel" Content="No" /> - <Label Grid.Row="4">Shared association?</Label> + <!--<Label Grid.Row="4">Shared association?</Label> <Label Grid.Row="4" Grid.Column="1" Name="sharedAssociationLabel" Content="Yes" /> - <Label Grid.Row="4" Grid.Column="1" Name="privateAssociationLabel" Content="No" /> + <Label Grid.Row="4" Grid.Column="1" Name="privateAssociationLabel" Content="No" />--> </Grid> </Expander> <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,12,0,0"> @@ -56,18 +56,18 @@ <TextBox Grid.Column="1" Name="claimedIdentifierBox" /> <Label Grid.Row="1">OP Local identifier</Label> <TextBox Grid.Column="1" Grid.Row="1" Name="localIdentifierBox" /> - <Label Grid.Row="2">Association</Label> + <!--<Label Grid.Row="2">Association</Label> <WrapPanel Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"> <RadioButton Margin="0,0,12,0" GroupName="AssociationType">Shared</RadioButton> <RadioButton GroupName="AssociationType">Private</RadioButton> - </WrapPanel> + </WrapPanel>--> </Grid> </StackPanel> </TabItem> <TabItem Header="Negative assertion" Name="negativeTab"> <TextBlock TextWrapping="Wrap">There is nothing to customize in a negative assertion.</TextBlock> </TabItem> - <TabItem Header="Error" Name="errorTab" > + <!--<TabItem Header="Error" Name="errorTab" > <StackPanel> <TextBlock TextWrapping="Wrap">What message do you want to send describing the simulated error?</TextBlock> <TextBox TextWrapping="Wrap" /> @@ -78,7 +78,7 @@ <TextBlock TextWrapping="Wrap">This tab is useful for testing a relying party's resiliance to invalid responses.</TextBlock> <TextBlock TextWrapping="Wrap">But it's not implemented yet. :)</TextBlock> </StackPanel> - </TabItem> + </TabItem>--> </TabControl> </DockPanel> </Window> diff --git a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs index 6bab2ae..597f72f 100644 --- a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs +++ b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs @@ -44,7 +44,10 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { this.discoverableYesLabel.Visibility = isRPDiscoverable ? Visibility.Visible : Visibility.Collapsed; this.discoverableNoLabel.Visibility = isRPDiscoverable ? Visibility.Collapsed : Visibility.Visible; - if (!request.IsDirectedIdentity) { + if (request.IsDirectedIdentity) { + this.claimedIdentifierBox.Text = provider.UserIdentityPageBase.AbsoluteUri; + this.localIdentifierBox.Text = provider.UserIdentityPageBase.AbsoluteUri; + } else { this.claimedIdentifierBox.Text = request.ClaimedIdentifier; this.localIdentifierBox.Text = request.LocalIdentifier; } @@ -55,31 +58,23 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { /// </summary> /// <param name="provider">The OpenID Provider host.</param> /// <param name="request">The incoming authentication request.</param> - /// <param name="skipUI">if set to <c>true</c> no dialog should be displayed to the user.</param> - internal static void ProcessAuthentication(HostedProvider provider, IAuthenticationRequest request, bool skipUI) { + internal static void ProcessAuthentication(HostedProvider provider, IAuthenticationRequest request) { Contract.Requires(provider != null); Contract.Requires(request != null); - if (skipUI) { - if (request.IsDirectedIdentity) { - throw new NotImplementedException(); - } - request.IsAuthenticated = true; - } else { - var window = new CheckIdWindow(provider, request); - bool? result = window.ShowDialog(); + var window = new CheckIdWindow(provider, request); + bool? result = window.ShowDialog(); - // If the user pressed Esc or cancel, just send a negative assertion. - if (!result.HasValue || !result.Value) { - request.IsAuthenticated = false; - return; - } + // If the user pressed Esc or cancel, just send a negative assertion. + if (!result.HasValue || !result.Value) { + request.IsAuthenticated = false; + return; + } - request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab; - if (request.IsAuthenticated.Value) { - request.ClaimedIdentifier = window.claimedIdentifierBox.Text; - request.LocalIdentifier = window.localIdentifierBox.Text; - } + request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab; + if (request.IsAuthenticated.Value) { + request.ClaimedIdentifier = window.claimedIdentifierBox.Text; + request.LocalIdentifier = window.localIdentifierBox.Text; } } diff --git a/samples/OpenIdOfflineProvider/HostedProvider.cs b/samples/OpenIdOfflineProvider/HostedProvider.cs index 785932e..54eb74c 100644 --- a/samples/OpenIdOfflineProvider/HostedProvider.cs +++ b/samples/OpenIdOfflineProvider/HostedProvider.cs @@ -68,6 +68,11 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { } /// <summary> + /// Gets or sets the delegate that handles authentication requests. + /// </summary> + internal Action<HttpRequestInfo, HttpListenerResponse> ProcessRequest { get; set; } + + /// <summary> /// Gets the provider endpoint. /// </summary> internal Uri ProviderEndpoint { @@ -78,21 +83,22 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { } /// <summary> - /// Gets or sets the delegate that handles authentication requests. + /// Gets the base URI that all user identities must start with. /// </summary> - internal Action<HttpRequestInfo, HttpListenerResponse> ProcessRequest { get; set; } + internal Uri UserIdentityPageBase { + get { + Contract.Requires(this.IsRunning); + return new Uri(this.httpHost.BaseUri, UserIdentifierPath); + } + } /// <summary> /// Gets the OP identifier. /// </summary> internal Uri OPIdentifier { get { - UriBuilder providerEndpointBuilder = new UriBuilder(); - providerEndpointBuilder.Scheme = Uri.UriSchemeHttp; - providerEndpointBuilder.Host = "localhost"; - providerEndpointBuilder.Port = this.httpHost.Port; - providerEndpointBuilder.Path = OPIdentifierPath; - return providerEndpointBuilder.Uri; + Contract.Requires(this.IsRunning); + return new Uri(this.httpHost.BaseUri, OPIdentifierPath); } } diff --git a/samples/OpenIdOfflineProvider/MainWindow.xaml b/samples/OpenIdOfflineProvider/MainWindow.xaml index 80fd4ea..de215ba 100644 --- a/samples/OpenIdOfflineProvider/MainWindow.xaml +++ b/samples/OpenIdOfflineProvider/MainWindow.xaml @@ -6,36 +6,20 @@ <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> <ColumnDefinition /> - <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> - <Label Grid.Row="1">OP Identifier</Label> - <Label Grid.Column="1" Grid.Row="1" Name="opIdentifierLabel" ToolTip="Click to copy URI to clipboard" MouseDown="opIdentifierLabel_MouseDown" /> - <Label Grid.Row="2">associate requests</Label> - <ComboBox Grid.Column="1" Grid.Row="2" Name="associateRequestList" SelectedIndex="0"> - <ComboBoxItem>Auto respond</ComboBoxItem> - <ComboBoxItem>Intercept</ComboBoxItem> - </ComboBox> - <Button Grid.Column="2" Grid.Row="2">Configure</Button> - <Label Grid.Row="3">checkid requests</Label> - <ComboBox Grid.Column="1" Grid.Row="3" Name="checkidRequestList" SelectedIndex="0"> - <ComboBoxItem>Auto respond</ComboBoxItem> - <ComboBoxItem>Intercept</ComboBoxItem> - </ComboBox> - <Button Grid.Column="2" Grid.Row="3">Configure</Button> - <Label Grid.Row="4">check__auth requests</Label> - <ComboBox Grid.Column="1" Grid.Row="4" Name="checkauthRequestList" SelectedIndex="0"> - <ComboBoxItem>Auto respond</ComboBoxItem> + <Label Grid.Row="0">OP Identifier</Label> + <Label Grid.Column="1" Grid.Row="0" Name="opIdentifierLabel" ToolTip="Click to copy URI to clipboard" MouseDown="opIdentifierLabel_MouseDown" /> + <Label Grid.Row="1">checkid requests</Label> + <ComboBox Grid.Column="1" Grid.Row="1" Name="checkidRequestList" SelectedIndex="0"> + <ComboBoxItem>Auto respond: Yes</ComboBoxItem> + <ComboBoxItem>Auto respond: No</ComboBoxItem> <ComboBoxItem>Intercept</ComboBoxItem> </ComboBox> - <Button Grid.Column="2" Grid.Row="4">Configure</Button> - <TextBox Height="auto" Grid.Row="5" Grid.ColumnSpan="3" Name="logBox" IsReadOnly="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" /> + <TextBox Height="auto" Margin="0,8,0,0" Grid.Row="2" Grid.ColumnSpan="2" Name="logBox" IsReadOnly="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" /> </Grid> </Window> diff --git a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs index 6018c20..56ce7b6 100644 --- a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs +++ b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs @@ -112,7 +112,21 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { if (!request.IsResponseReady) { var authRequest = request as IAuthenticationRequest; if (authRequest != null) { - CheckIdWindow.ProcessAuthentication(this.hostedProvider, authRequest, checkidRequestList.SelectedIndex == 0); + switch (checkidRequestList.SelectedIndex) { + case 0: + if (authRequest.IsDirectedIdentity) { + authRequest.ClaimedIdentifier = new Uri(this.hostedProvider.UserIdentityPageBase, "directedidentity"); + authRequest.LocalIdentifier = authRequest.ClaimedIdentifier; + } + authRequest.IsAuthenticated = true; + break; + case 1: + authRequest.IsAuthenticated = false; + break; + case 2: + CheckIdWindow.ProcessAuthentication(this.hostedProvider, authRequest); + break; + } } } }); |