summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2.AuthorizationServer
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.AuthorizationServer')
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj1
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs71
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenAuthorizationCodeRequestAS.cs9
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenRefreshRequestAS.cs8
4 files changed, 72 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj
index f2da960..c28de19 100644
--- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj
@@ -29,6 +29,7 @@
<Compile Include="OAuth2\ChannelElements\IOAuth2ChannelWithAuthorizationServer.cs" />
<Compile Include="OAuth2\ChannelElements\OAuth2AuthorizationServerChannel.cs" />
<Compile Include="OAuth2\ChannelElements\RefreshToken.cs" />
+ <Compile Include="OAuth2\ClientDescription.cs" />
<Compile Include="OAuth2\Messages\AccessTokenAuthorizationCodeRequestAS.cs" />
<Compile Include="OAuth2\Messages\AccessTokenRefreshRequestAS.cs" />
<Compile Include="OAuth2\Messages\EndUserAuthorizationSuccessAuthCodeResponseAS.cs" />
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs
new file mode 100644
index 0000000..76c3ea6
--- /dev/null
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs
@@ -0,0 +1,71 @@
+//-----------------------------------------------------------------------
+// <copyright file="ClientDescription.cs" company="Outercurve Foundation">
+// Copyright (c) Outercurve Foundation. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OAuth2 {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ /// <summary>
+ /// A default implementation of the <see cref="IClientDescription"/> interface.
+ /// </summary>
+ public class ClientDescription : IClientDescription {
+ /// <summary>
+ /// A delegate that determines whether the callback is allowed.
+ /// </summary>
+ private readonly Func<Uri, bool> isCallbackAllowed;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ClientDescription"/> class.
+ /// </summary>
+ /// <param name="secret">The secret.</param>
+ /// <param name="defaultCallback">The default callback.</param>
+ /// <param name="clientType">Type of the client.</param>
+ /// <param name="isCallbackAllowed">A delegate that determines whether the callback is allowed.</param>
+ public ClientDescription(string secret, Uri defaultCallback, ClientType clientType, Func<Uri, bool> isCallbackAllowed = null) {
+ this.Secret = secret;
+ this.DefaultCallback = defaultCallback;
+ this.ClientType = clientType;
+ this.isCallbackAllowed = isCallbackAllowed;
+ }
+
+ /// <summary>
+ /// Gets the client secret.
+ /// </summary>
+ public string Secret { get; private set; }
+
+ /// <summary>
+ /// Gets the callback to use when an individual authorization request
+ /// does not include an explicit callback URI.
+ /// </summary>
+ /// <value>
+ /// An absolute URL; or <c>null</c> if none is registered.
+ /// </value>
+ public Uri DefaultCallback { get; private set; }
+
+ /// <summary>
+ /// Gets the type of the client.
+ /// </summary>
+ public ClientType ClientType { get; private set; }
+
+ /// <summary>
+ /// Determines whether a callback URI included in a client's authorization request
+ /// is among those allowed callbacks for the registered client.
+ /// </summary>
+ /// <param name="callback">The absolute URI the client has requested the authorization result be received at.</param>
+ /// <returns>
+ /// <c>true</c> if the callback URL is allowable for this client; otherwise, <c>false</c>.
+ /// </returns>
+ public bool IsCallbackAllowed(Uri callback) {
+ if (this.isCallbackAllowed != null) {
+ return this.isCallbackAllowed(callback);
+ }
+
+ return EqualityComparer<Uri>.Default.Equals(this.DefaultCallback, callback);
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenAuthorizationCodeRequestAS.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenAuthorizationCodeRequestAS.cs
index 0d071d0..2944bc3 100644
--- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenAuthorizationCodeRequestAS.cs
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenAuthorizationCodeRequestAS.cs
@@ -24,15 +24,6 @@ namespace DotNetOpenAuth.OAuth2.Messages {
: base(tokenEndpoint, version) {
}
- /// <summary>
- /// Initializes a new instance of the <see cref="AccessTokenAuthorizationCodeRequest"/> class.
- /// </summary>
- /// <param name="authorizationServer">The authorization server.</param>
- internal AccessTokenAuthorizationCodeRequestAS(AuthorizationServerDescription authorizationServer)
- : this(authorizationServer.TokenEndpoint, authorizationServer.Version) {
- Requires.NotNull(authorizationServer, "authorizationServer");
- }
-
#region IAuthorizationCodeCarryingRequest Members
/// <summary>
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenRefreshRequestAS.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenRefreshRequestAS.cs
index 22fdc7a..4410e27 100644
--- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenRefreshRequestAS.cs
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/Messages/AccessTokenRefreshRequestAS.cs
@@ -26,14 +26,6 @@ namespace DotNetOpenAuth.OAuth2.AuthServer.Messages {
: base(tokenEndpoint, version) {
}
- /// <summary>
- /// Initializes a new instance of the <see cref="AccessTokenRefreshRequestAS"/> class.
- /// </summary>
- /// <param name="authorizationServer">The authorization server.</param>
- internal AccessTokenRefreshRequestAS(AuthorizationServerDescription authorizationServer)
- : this(authorizationServer.TokenEndpoint, authorizationServer.Version) {
- }
-
#region IRefreshTokenCarryingRequest members
/// <summary>