diff options
Diffstat (limited to 'src')
15 files changed, 56 insertions, 45 deletions
diff --git a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj index 00c7fc2..6afe84c 100644 --- a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj +++ b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj @@ -93,7 +93,7 @@ <Compile Include="Scenarios\AppendixScenarios.cs" />
<Compile Include="Scenarios\CoordinatingOAuthChannel.cs" />
<Compile Include="Scenarios\Coordinator.cs" />
- <Compile Include="ServiceProviderEndpointsTests.cs" />
+ <Compile Include="ServiceProviderDescriptionTests.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="UriUtilTests.cs" />
</ItemGroup>
diff --git a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs index 0d73b22..5bd4629 100644 --- a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs +++ b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs @@ -19,19 +19,19 @@ namespace DotNetOAuth.Test { public class AppendixScenarios : TestBase {
[TestMethod]
public void SpecAppendixAExample() {
- ServiceProviderEndpoints endpoints = new ServiceProviderEndpoints() {
+ ServiceProviderDescription serviceDescription = new ServiceProviderDescription() {
RequestTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/request_token", HttpDeliveryMethod.PostRequest),
UserAuthorizationEndpoint = new MessageReceivingEndpoint("http://photos.example.net/authorize", HttpDeliveryMethod.GetRequest),
AccessTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/access_token", HttpDeliveryMethod.PostRequest),
+ TamperProtectionElements = new ITamperProtectionChannelBindingElement[] {
+ new PlainTextSigningBindingElement(),
+ new HmacSha1SigningBindingElement(),
+ },
};
MessageReceivingEndpoint accessPhotoEndpoint = new MessageReceivingEndpoint("http://photos.example.net/photos?file=vacation.jpg&size=original", HttpDeliveryMethod.AuthorizationHeaderRequest);
var tokenManager = new InMemoryTokenManager();
- ITamperProtectionChannelBindingElement[] signers = new ITamperProtectionChannelBindingElement[] {
- new PlainTextSigningBindingElement(),
- new HmacSha1SigningBindingElement(),
- };
- var sp = new ServiceProvider(endpoints, tokenManager, signers);
- Consumer consumer = new Consumer(endpoints, new InMemoryTokenManager(), signers) {
+ var sp = new ServiceProvider(serviceDescription, tokenManager);
+ Consumer consumer = new Consumer(serviceDescription, new InMemoryTokenManager()) {
ConsumerKey = "dpf43f3p2l4k3l03",
ConsumerSecret = "kd94hf93k423kf44",
};
diff --git a/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs b/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs index 843df09..99543c1 100644 --- a/src/DotNetOAuth.Test/ServiceProviderEndpointsTests.cs +++ b/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="ServiceProviderEndpointsTests.cs" company="Andrew Arnott">
+// <copyright file="ServiceProviderDescriptionTests.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -13,13 +13,13 @@ namespace DotNetOAuth.Test { /// Tests for the <see cref="ServiceProviderEndpoints"/> class.
/// </summary>
[TestClass]
- public class ServiceProviderEndpointsTests : TestBase {
+ public class ServiceProviderDescriptionTests : TestBase {
/// <summary>
/// A test for UserAuthorizationUri
/// </summary>
[TestMethod]
public void UserAuthorizationUriTest() {
- ServiceProviderEndpoints target = new ServiceProviderEndpoints();
+ ServiceProviderDescription target = new ServiceProviderDescription();
MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethod.GetRequest);
MessageReceivingEndpoint actual;
target.UserAuthorizationEndpoint = expected;
@@ -35,7 +35,7 @@ namespace DotNetOAuth.Test { /// </summary>
[TestMethod]
public void RequestTokenUriTest() {
- var target = new ServiceProviderEndpoints();
+ var target = new ServiceProviderDescription();
MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethod.GetRequest);
MessageReceivingEndpoint actual;
target.RequestTokenEndpoint = expected;
@@ -52,7 +52,7 @@ namespace DotNetOAuth.Test { /// </summary>
[TestMethod, ExpectedException(typeof(ArgumentException))]
public void RequestTokenUriWithOAuthParametersTest() {
- var target = new ServiceProviderEndpoints();
+ var target = new ServiceProviderDescription();
target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethod.GetRequest);
}
@@ -61,7 +61,7 @@ namespace DotNetOAuth.Test { /// </summary>
[TestMethod]
public void AccessTokenUriTest() {
- var target = new ServiceProviderEndpoints();
+ var target = new ServiceProviderDescription();
MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethod.GetRequest);
MessageReceivingEndpoint actual;
target.AccessTokenEndpoint = expected;
diff --git a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs index caeeb7c..a6117d0 100644 --- a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs +++ b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs @@ -11,7 +11,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Additional properties that apply specifically to OAuth messages.
/// </summary>
- internal interface IOAuthDirectedMessage : IDirectedProtocolMessage {
+ public interface IOAuthDirectedMessage : IDirectedProtocolMessage {
/// <summary>
/// Gets the preferred method of transport for the message.
/// </summary>
diff --git a/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs b/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs index 926dcfb..500f65c 100644 --- a/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs +++ b/src/DotNetOAuth/ChannelElements/ITamperResistantOAuthMessage.cs @@ -12,7 +12,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// An interface that OAuth messages implement to support signing.
/// </summary>
- internal interface ITamperResistantOAuthMessage : IOAuthDirectedMessage, ITamperResistantProtocolMessage {
+ public interface ITamperResistantOAuthMessage : IOAuthDirectedMessage, ITamperResistantProtocolMessage {
/// <summary>
/// Gets or sets the method used to sign the message.
/// </summary>
diff --git a/src/DotNetOAuth/Consumer.cs b/src/DotNetOAuth/Consumer.cs index 2d9355e..d61eb0b 100644 --- a/src/DotNetOAuth/Consumer.cs +++ b/src/DotNetOAuth/Consumer.cs @@ -19,21 +19,21 @@ namespace DotNetOAuth { /// <summary>
/// Initializes a new instance of the <see cref="Consumer"/> class.
/// </summary>
- /// <param name="endpoints">The endpoints on the Service Provider.</param>
+ /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
/// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
- internal Consumer(ServiceProviderEndpoints endpoints, ITokenManager tokenManager, params ITamperProtectionChannelBindingElement[] signingElements) {
- if (endpoints == null) {
- throw new ArgumentNullException("endpoints");
+ internal Consumer(ServiceProviderDescription serviceDescription, ITokenManager tokenManager) {
+ if (serviceDescription == null) {
+ throw new ArgumentNullException("serviceDescription");
}
if (tokenManager == null) {
throw new ArgumentNullException("tokenManager");
}
this.WebRequestHandler = new StandardWebRequestHandler();
- ITamperProtectionChannelBindingElement signingElement = new SigningBindingElementChain(signingElements);
+ ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge);
this.Channel = new OAuthChannel(signingElement, store, new OAuthMessageTypeProvider(tokenManager), this.WebRequestHandler);
- this.ServiceProvider = endpoints;
+ this.ServiceProvider = serviceDescription;
this.TokenManager = tokenManager;
}
@@ -50,7 +50,7 @@ namespace DotNetOAuth { /// <summary>
/// Gets the Service Provider that will be accessed.
/// </summary>
- public ServiceProviderEndpoints ServiceProvider { get; private set; }
+ public ServiceProviderDescription ServiceProvider { get; private set; }
/// <summary>
/// Gets the persistence store for tokens and secrets.
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index 6cecde1..4645a41 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -65,7 +65,7 @@ <Compile Include="ChannelElements\StandardTokenGenerator.cs" />
<Compile Include="ChannelElements\TokenType.cs" />
<Compile Include="Messaging\ITamperProtectionChannelBindingElement.cs" />
- <Compile Include="ServiceProviderEndpoints.cs" />
+ <Compile Include="ServiceProviderDescription.cs" />
<Compile Include="Messages\ITokenContainingMessage.cs" />
<Compile Include="Messages\SignedMessageBase.cs" />
<Compile Include="Messaging\Bindings\NonceMemoryStore.cs" />
diff --git a/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs b/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs index b1d960f..62c3088 100644 --- a/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs @@ -8,7 +8,7 @@ namespace DotNetOAuth.Messaging.Bindings { /// <summary>
/// The contract a message that is signed must implement.
/// </summary>
- internal interface ITamperResistantProtocolMessage : IProtocolMessage {
+ public interface ITamperResistantProtocolMessage : IProtocolMessage {
/// <summary>
/// Gets or sets the message signature.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/IChannelBindingElement.cs b/src/DotNetOAuth/Messaging/IChannelBindingElement.cs index 71127f4..25f353f 100644 --- a/src/DotNetOAuth/Messaging/IChannelBindingElement.cs +++ b/src/DotNetOAuth/Messaging/IChannelBindingElement.cs @@ -14,7 +14,7 @@ namespace DotNetOAuth.Messaging { /// An interface that must be implemented by message transforms/validators in order
/// to be included in the channel stack.
/// </summary>
- internal interface IChannelBindingElement {
+ public interface IChannelBindingElement {
/// <summary>
/// Gets the protection offered (if any) by this binding element.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/IDirectedProtocolMessage.cs b/src/DotNetOAuth/Messaging/IDirectedProtocolMessage.cs index bebd303..8479fef 100644 --- a/src/DotNetOAuth/Messaging/IDirectedProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/IDirectedProtocolMessage.cs @@ -11,7 +11,7 @@ namespace DotNetOAuth.Messaging { /// Implemented by messages that have explicit recipients
/// (direct requests and all indirect messages).
/// </summary>
- internal interface IDirectedProtocolMessage : IProtocolMessage {
+ public interface IDirectedProtocolMessage : IProtocolMessage {
/// <summary>
/// Gets the URL of the intended receiver of this message.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/IProtocolMessage.cs b/src/DotNetOAuth/Messaging/IProtocolMessage.cs index c353c71..53b77d6 100644 --- a/src/DotNetOAuth/Messaging/IProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/IProtocolMessage.cs @@ -13,7 +13,7 @@ namespace DotNetOAuth.Messaging { /// The interface that classes must implement to be serialized/deserialized
/// as OAuth messages.
/// </summary>
- internal interface IProtocolMessage {
+ public interface IProtocolMessage {
/// <summary>
/// Gets the version of the protocol this message is prepared to implement.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs b/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs index 40203e9..de900db 100644 --- a/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs +++ b/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs @@ -12,7 +12,7 @@ namespace DotNetOAuth.Messaging { /// An interface that must be implemented by message transforms/validators in order
/// to be included in the channel stack.
/// </summary>
- internal interface ITamperProtectionChannelBindingElement : IChannelBindingElement {
+ public interface ITamperProtectionChannelBindingElement : IChannelBindingElement {
/// <summary>
/// Gets or sets the delegate that will initialize the non-serialized properties necessary on a signed
/// message so that its signature can be correctly calculated for verification.
diff --git a/src/DotNetOAuth/Messaging/MessageProtection.cs b/src/DotNetOAuth/Messaging/MessageProtection.cs index a50ccf5..9dc2b9d 100644 --- a/src/DotNetOAuth/Messaging/MessageProtection.cs +++ b/src/DotNetOAuth/Messaging/MessageProtection.cs @@ -17,7 +17,7 @@ namespace DotNetOAuth.Messaging { /// tamper protection to prevent a user from changing the timestamp on a message.
/// </remarks>
[Flags]
- internal enum MessageProtection {
+ public enum MessageProtection {
/// <summary>
/// No protection.
/// </summary>
diff --git a/src/DotNetOAuth/ServiceProvider.cs b/src/DotNetOAuth/ServiceProvider.cs index ad629a3..778f9df 100644 --- a/src/DotNetOAuth/ServiceProvider.cs +++ b/src/DotNetOAuth/ServiceProvider.cs @@ -28,29 +28,29 @@ namespace DotNetOAuth { /// <summary>
/// Initializes a new instance of the <see cref="ServiceProvider"/> class.
/// </summary>
- /// <param name="endpoints">The endpoints on the Service Provider.</param>
+ /// <param name="serviceDescription">The endpoints and behavior on the Service Provider.</param>
/// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
- internal ServiceProvider(ServiceProviderEndpoints endpoints, ITokenManager tokenManager, params ITamperProtectionChannelBindingElement[] signingElements) {
- if (endpoints == null) {
- throw new ArgumentNullException("endpoints");
+ internal ServiceProvider(ServiceProviderDescription serviceDescription, ITokenManager tokenManager) {
+ if (serviceDescription == null) {
+ throw new ArgumentNullException("serviceDescription");
}
if (tokenManager == null) {
throw new ArgumentNullException("tokenManager");
}
- ITamperProtectionChannelBindingElement signingElement = new SigningBindingElementChain(signingElements);
+ var signingElement = serviceDescription.CreateTamperProtectionElement();
signingElement.SignatureVerificationCallback = this.TokenSignatureVerificationCallback;
INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge);
- this.Endpoints = endpoints;
+ this.Description = serviceDescription;
this.Channel = new OAuthChannel(signingElement, store, tokenManager);
this.TokenGenerator = new StandardTokenGenerator();
this.TokenManager = tokenManager;
}
/// <summary>
- /// Gets the endpoints exposed by this Service Provider.
+ /// Gets the description of this Service Provider.
/// </summary>
- public ServiceProviderEndpoints Endpoints { get; private set; }
+ public ServiceProviderDescription Description { get; private set; }
/// <summary>
/// Gets the pending user agent redirect based message to be sent as an HttpResponse.
diff --git a/src/DotNetOAuth/ServiceProviderEndpoints.cs b/src/DotNetOAuth/ServiceProviderDescription.cs index 82bdf28..2148a8a 100644 --- a/src/DotNetOAuth/ServiceProviderEndpoints.cs +++ b/src/DotNetOAuth/ServiceProviderDescription.cs @@ -1,29 +1,27 @@ //-----------------------------------------------------------------------
-// <copyright file="ServiceProviderEndpoints.cs" company="Andrew Arnott">
+// <copyright file="ServiceProviderDescription.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOAuth {
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
+ using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messaging;
/// <summary>
/// A description of the endpoints on a Service Provider.
/// </summary>
- public class ServiceProviderEndpoints {
+ public class ServiceProviderDescription {
/// <summary>
/// The field used to store the value of the <see cref="RequestTokenEndpoint"/> property.
/// </summary>
private MessageReceivingEndpoint requestTokenEndpoint;
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProviderEndpoints"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProviderDescription"/> class.
/// </summary>
- public ServiceProviderEndpoints() {
+ public ServiceProviderDescription() {
}
/// <summary>
@@ -67,5 +65,18 @@ namespace DotNetOAuth { /// This is the URL that <see cref="Messages.RequestAccessTokenMessage"/> messages are directed to.
/// </remarks>
public MessageReceivingEndpoint AccessTokenEndpoint { get; set; }
+
+ /// <summary>
+ /// Gets or sets the signing policies that apply to this Service Provider.
+ /// </summary>
+ public ITamperProtectionChannelBindingElement[] TamperProtectionElements { get; set; }
+
+ /// <summary>
+ /// Creates a signing element that includes all the signing elements this service provider supports.
+ /// </summary>
+ /// <returns>The created signing element.</returns>
+ internal ITamperProtectionChannelBindingElement CreateTamperProtectionElement() {
+ return new SigningBindingElementChain(this.TamperProtectionElements);
+ }
}
}
|