Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
Merge branch 'v2.2' into v2.3
Browse files Browse the repository at this point in the history
Conflicts:

	src/DotNetOpenId/RelyingParty/OpenIdRelyingParty.cs
	src/version.txt
  • Loading branch information
AArnott committed Aug 5, 2008
2 parents 1d7a358 + 87fd612 commit 8b78d9e
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 19 deletions.
9 changes: 5 additions & 4 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<DirtyDirectories Include="@(SampleDirectories->'%(FullPath)\obj')" />
<DirtyFiles Include="
$(ProjectRoot)\**\*~;
$(ProjectRoot)\**\*Trace.txt;
$(ProjectRoot)\**\*.log*;
$(ProjectRoot)\doc\DotNetOpenId.chm;
" />
</ItemGroup>
Expand Down Expand Up @@ -105,7 +105,7 @@
$(ProjectRoot)\**\*.user;
$(ProjectRoot)\**\*.gitignore;
$(ProjectRoot)\**\*.ldf;
$(ProjectRoot)\**\*Trace.txt;
$(ProjectRoot)\**\*.log*;
$(ProjectRoot)\**\*~;
" />
<DropSpecsSourceFiles Include="$(ProjectRoot)\Doc\specs\*.htm*" />
Expand All @@ -130,13 +130,14 @@
@(DropDocFiles);
@(DropSpecsFiles)
" />

<SampleProjectTargets Include="$(DropSamplesDirectory)\**\*.csproj" />
</ItemGroup>

<MakeDir Directories="@(DropDirectories)" />
<Copy SourceFiles="@(AllDropSources)" DestinationFiles="@(AllDropTargets)" SkipUnchangedFiles="true" />
<!-- fix up the samples so that they will compile right out of the drop -->
<ItemGroup>
<SampleProjectTargets Include="$(DropSamplesDirectory)\**\*.csproj" />
</ItemGroup>
<ChangeProjectReferenceToAssemblyReference Projects="@(SampleProjectTargets)"
ProjectReference="..\..\src\DotNetOpenId\DotNetOpenId.csproj" Reference="..\..\Bin\DotNetOpenId.dll" />
<Zip Files="@(AllDropTargets)" ZipFileName="$(DropZip)" WorkingDirectory="$(ProjectRoot)\drops" />
Expand Down
6 changes: 5 additions & 1 deletion samples/ProviderPortal/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
}
</script>

<asp:Content runat=server ContentPlaceHolderID=Main>
<asp:Content runat="server" ContentPlaceHolderID="head">
<openid:XrdsPublisher runat="server" XrdsUrl="~/op_xrds.aspx" />
</asp:Content>

<asp:Content runat="server" ContentPlaceHolderID="Main">
<h2>
Provider
</h2>
Expand Down
2 changes: 1 addition & 1 deletion samples/ProviderPortal/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</location>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="op.txt" />
<file value="Provider.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
Expand Down
2 changes: 1 addition & 1 deletion samples/RelyingPartyPortal/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</system.web>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="rp.txt" />
<file value="RelyingParty.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
Expand Down
5 changes: 5 additions & 0 deletions src/DotNetOpenId/IEncodable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ internal enum EncodingType {
internal interface IEncodable {
EncodingType EncodingType { get; }
IDictionary<string, string> EncodedFields { get; }
/// <summary>
/// The URL that the user agent should be redirected to
/// in the case of <see cref="DotNetOpenId.EncodingType.IndirectMessage"/>.
/// Does not apply to <see cref="DotNetOpenId.EncodingType.DirectResponse"/>.
/// </summary>
Uri RedirectUrl { get; }
Protocol Protocol { get; }
}
Expand Down
8 changes: 2 additions & 6 deletions src/DotNetOpenId/IResponse.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Collections.Specialized;
using System.Net;

namespace DotNetOpenId {
/// <summary>
/// Represents a Provider's response to an OpenId authentication request.
/// Represents an indirect message passed between Relying Party and Provider.
/// </summary>
public interface IResponse {
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/DotNetOpenId/MessageEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ internal class MessageEncoder {
/// Encodes messages into <see cref="Response"/> instances.
/// </summary>
public virtual Response Encode(IEncodable message) {
if (message == null) throw new ArgumentNullException("message");

EncodingType encode_as = message.EncodingType;
Response wr;

Expand All @@ -59,7 +61,7 @@ public virtual Response Encode(IEncodable message) {
wr = new Response(code, headers, ProtocolMessages.KeyValueForm.GetBytes(message.EncodedFields), message);
break;
case EncodingType.IndirectMessage:
Logger.DebugFormat("Sending indirect message response:{0}{1}",
Logger.DebugFormat("Sending indirect message:{0}{1}",
Environment.NewLine, Util.ToString(message.EncodedFields));
// TODO: either redirect or do a form POST depending on payload size.
Debug.Assert(message.RedirectUrl != null);
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetOpenId/RelyingParty/AuthenticationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public bool IsDirectedIdentity {
/// </summary>
IProviderEndpoint IAuthenticationRequest.Provider { get { return endpoint; } }
/// <summary>
/// Gets the URL the user agent should be redirected to to begin the
/// Gets the response to send to the user agent to begin the
/// OpenID authentication process.
/// </summary>
public IResponse RedirectingResponse {
Expand Down
7 changes: 6 additions & 1 deletion src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ internal AuthenticationResponse(AuthenticationStatus status, ServiceEndpoint pro
if (provider == null) throw new ArgumentNullException("provider");
if (query == null) throw new ArgumentNullException("query");

Logger.InfoFormat("Verified positive authentication assertion for: {0}", provider.ClaimedIdentifier);
if (status == AuthenticationStatus.Authenticated) {
Logger.InfoFormat("Verified positive authentication assertion for: {0}", provider.ClaimedIdentifier);
} else {
Logger.InfoFormat("Negative authentication assertion received: {0}", status);
}

Status = status;
Provider = provider;
signedArguments = new Dictionary<string, string>();
Expand Down
3 changes: 0 additions & 3 deletions src/DotNetOpenId/RelyingParty/IndirectMessageRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public IndirectMessageRequest(Uri receivingUrl, IDictionary<string, string> fiel
if (fields == null) throw new ArgumentNullException("fields");
RedirectUrl = receivingUrl;
EncodedFields = fields;

Logger.DebugFormat("Preparing indirect message:{0}{1}", Environment.NewLine,
Util.ToString(fields));
}

#region IEncodable Members
Expand Down
100 changes: 100 additions & 0 deletions src/DotNetOpenId/RelyingParty/OpenIdRelyingParty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,79 @@ namespace DotNetOpenId.RelyingParty {
/// <summary>
/// Provides the programmatic facilities to act as an OpenId consumer.
/// </summary>
/// <remarks>
/// For easier, ASP.NET designer drop-in support for adding OpenID login support,
/// see the <see cref="OpenIdLogin"/> or <see cref="OpenIdTextBox"/> controls.
/// </remarks>
/// <example>
/// <code language="ASP.NET">
///&lt;h2&gt;Login Page &lt;/h2&gt;
///&lt;asp:Label ID="Label1" runat="server" Text="OpenID Login" /&gt;
///&lt;asp:TextBox ID="openIdBox" runat="server" /&gt;
///&lt;asp:Button ID="loginButton" runat="server" Text="Login" OnClick="loginButton_Click" /&gt;
///&lt;asp:CustomValidator runat="server" ID="openidValidator" ErrorMessage="Invalid OpenID Identifier"
/// ControlToValidate="openIdBox" EnableViewState="false" OnServerValidate="openidValidator_ServerValidate" /&gt;
///&lt;br /&gt;
///&lt;asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed"
/// Visible="False" /&gt;
///&lt;asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled"
/// Visible="False" /&gt;
/// </code>
/// <code language="c#">
///protected void openidValidator_ServerValidate(object source, ServerValidateEventArgs args) {
/// // This catches common typos that result in an invalid OpenID Identifier.
/// args.IsValid = Identifier.IsValid(args.Value);
///}
///
///protected void loginButton_Click(object sender, EventArgs e) {
/// if (!Page.IsValid) return; // don't login if custom validation failed.
/// OpenIdRelyingParty openid = new OpenIdRelyingParty();
/// try {
/// IAuthenticationRequest request = openid.CreateRequest(openIdBox.Text);
/// // This is where you would add any OpenID extensions you wanted
/// // to include in the authentication request.
/// // request.AddExtension(someExtensionRequestInstance);
///
/// // Send your visitor to their Provider for authentication.
/// request.RedirectToProvider();
/// } catch (OpenIdException ex) {
/// // The user probably entered an Identifier that
/// // was not a valid OpenID endpoint.
/// openidValidator.Text = ex.Message;
/// openidValidator.IsValid = false;
/// }
///}
///
///protected void Page_Load(object sender, EventArgs e) {
/// openIdBox.Focus();
///
/// OpenIdRelyingParty openid = new OpenIdRelyingParty();
/// if (openid.Response != null) {
/// switch (openid.Response.Status) {
/// case AuthenticationStatus.Authenticated:
/// // This is where you would look for any OpenID extension responses included
/// // in the authentication assertion.
/// // var extension = openid.Response.GetExtension&lt;SomeExtensionResponseType&gt;();
///
/// // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
/// // with the OpenID Claimed Identifier as their username.
/// FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
/// break;
/// case AuthenticationStatus.Canceled:
/// loginCanceledLabel.Visible = true;
/// break;
/// case AuthenticationStatus.Failed:
/// loginFailedLabel.Visible = true;
/// break;
/// // We don't need to handle SetupRequired because we're not setting
/// // IAuthenticationRequest.Mode to immediate mode.
/// //case AuthenticationStatus.SetupRequired:
/// // break;
/// }
/// }
///}
/// </code>
/// </example>
[DebuggerDisplay("isAuthenticationResponseReady: {isAuthenticationResponseReady}, stateless: {store == null}")]
public class OpenIdRelyingParty {
IRelyingPartyApplicationStore store;
Expand Down Expand Up @@ -93,6 +166,22 @@ public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, R
return AuthenticationRequest.Create(userSuppliedIdentifier, this, realm, returnToUrl, store);
}

/// <summary>
/// Creates an authentication request to verify that a user controls
/// some given Identifier.
/// </summary>
/// <param name="userSuppliedIdentifier">
/// The Identifier supplied by the user. This may be a URL, an XRI or i-name.
/// </param>
/// <param name="realm">
/// The shorest URL that describes this relying party web site's address.
/// For example, if your login page is found at https://www.example.com/login.aspx,
/// your realm would typically be https://www.example.com/.
/// </param>
/// <returns>
/// An authentication request object that describes the HTTP response to
/// send to the user agent to initiate the authentication.
/// </returns>
/// <remarks>
/// This method requires an ASP.NET HttpContext.
/// </remarks>
Expand Down Expand Up @@ -121,6 +210,17 @@ internal static bool ShouldParameterBeStrippedFromReturnToUrl(string parameterNa
|| parameterName == Token.TokenKey;
}

/// <summary>
/// Creates an authentication request to verify that a user controls
/// some given Identifier.
/// </summary>
/// <param name="userSuppliedIdentifier">
/// The Identifier supplied by the user. This may be a URL, an XRI or i-name.
/// </param>
/// <returns>
/// An authentication request object that describes the HTTP response to
/// send to the user agent to initiate the authentication.
/// </returns>
/// <remarks>
/// This method requires an ASP.NET HttpContext.
/// </remarks>
Expand Down

0 comments on commit 8b78d9e

Please sign in to comment.