diff options
Diffstat (limited to 'src')
7 files changed, 25 insertions, 27 deletions
diff --git a/src/DotNetOAuth.Test/Scenarios/Coordinator.cs b/src/DotNetOAuth.Test/Scenarios/Coordinator.cs index 00aa625..f11c63e 100644 --- a/src/DotNetOAuth.Test/Scenarios/Coordinator.cs +++ b/src/DotNetOAuth.Test/Scenarios/Coordinator.cs @@ -58,6 +58,7 @@ namespace DotNetOAuth.Test.Scenarios { // Prepare token managers
InMemoryTokenManager consumerTokenManager = new InMemoryTokenManager();
InMemoryTokenManager serviceTokenManager = new InMemoryTokenManager();
+ consumerTokenManager.AddConsumer(this.consumerDescription);
serviceTokenManager.AddConsumer(this.consumerDescription);
// Prepare channels that will pass messages directly back and forth.
@@ -70,7 +71,6 @@ namespace DotNetOAuth.Test.Scenarios { WebConsumer consumer = new WebConsumer(this.serviceDescription, consumerTokenManager) {
Channel = consumerChannel,
ConsumerKey = this.consumerDescription.ConsumerKey,
- ConsumerSecret = this.consumerDescription.ConsumerSecret,
};
ServiceProvider serviceProvider = new ServiceProvider(this.serviceDescription, serviceTokenManager) {
Channel = serviceProviderChannel,
diff --git a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs index 8006dd9..7741931 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs @@ -72,11 +72,11 @@ namespace DotNetOAuth.ChannelElements { this.webRequestHandler = webRequestHandler;
this.TokenManager = tokenManager;
- if (signingBindingElement.SignatureVerificationCallback != null) {
+ if (signingBindingElement.SignatureCallback != null) {
throw new ArgumentException(Strings.SigningElementAlreadyAssociatedWithChannel, "signingBindingElement");
}
- signingBindingElement.SignatureVerificationCallback = this.TokenSignatureVerificationCallback;
+ signingBindingElement.SignatureCallback = this.SignatureCallback;
}
/// <summary>
@@ -373,11 +373,12 @@ namespace DotNetOAuth.ChannelElements { }
/// <summary>
- /// Fills out the secrets in an incoming message so that signature verification can be performed.
+ /// Fills out the secrets in a message so that signing/verification can be performed.
/// </summary>
- /// <param name="message">The incoming message.</param>
- private void TokenSignatureVerificationCallback(ITamperResistantOAuthMessage message) {
+ /// <param name="message">The message about to be signed or whose signature is about to be verified.</param>
+ private void SignatureCallback(ITamperResistantOAuthMessage message) {
try {
+ Logger.Debug("Applying secrets to message to prepare for signing or signature verification.");
message.ConsumerSecret = this.TokenManager.GetConsumerSecret(message.ConsumerKey);
var tokenMessage = message as ITokenContainingMessage;
diff --git a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs index 20eab0f..dab4c19 100644 --- a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs @@ -46,7 +46,7 @@ namespace DotNetOAuth.ChannelElements { /// 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.
/// </summary>
- public Action<ITamperResistantOAuthMessage> SignatureVerificationCallback { get; set; }
+ public Action<ITamperResistantOAuthMessage> SignatureCallback { get; set; }
/// <summary>
/// Creates a new object that is a copy of the current instance.
@@ -56,7 +56,7 @@ namespace DotNetOAuth.ChannelElements { /// </returns>
ITamperProtectionChannelBindingElement ITamperProtectionChannelBindingElement.Clone() {
ITamperProtectionChannelBindingElement clone = this.Clone();
- clone.SignatureVerificationCallback = this.SignatureVerificationCallback;
+ clone.SignatureCallback = this.SignatureCallback;
return clone;
}
@@ -72,6 +72,12 @@ namespace DotNetOAuth.ChannelElements { public bool PrepareMessageForSending(IProtocolMessage message) {
var signedMessage = message as ITamperResistantOAuthMessage;
if (signedMessage != null && this.IsMessageApplicable(signedMessage)) {
+ if (this.SignatureCallback != null) {
+ this.SignatureCallback(signedMessage);
+ } else {
+ Logger.Warn("Signing required, but callback delegate was not provided to provide additional data for signing.");
+ }
+
signedMessage.SignatureMethod = this.signatureMethod;
Logger.DebugFormat("Signing {0} message using {1}.", message.GetType().Name, this.signatureMethod);
signedMessage.Signature = this.GetSignature(signedMessage);
@@ -97,8 +103,8 @@ namespace DotNetOAuth.ChannelElements { return false;
}
- if (this.SignatureVerificationCallback != null) {
- this.SignatureVerificationCallback(signedMessage);
+ if (this.SignatureCallback != null) {
+ this.SignatureCallback(signedMessage);
} else {
Logger.Warn("Signature verification required, but callback delegate was not provided to provide additional data for signing.");
}
diff --git a/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs b/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs index dada28e..2d490d2 100644 --- a/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs +++ b/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs @@ -53,14 +53,14 @@ namespace DotNetOAuth.ChannelElements { /// message so that its signature can be correctly calculated for verification.
/// May be null for Consumers (who never have to verify signatures).
/// </summary>
- public Action<ITamperResistantOAuthMessage> SignatureVerificationCallback {
+ public Action<ITamperResistantOAuthMessage> SignatureCallback {
get {
- return this.signers[0].SignatureVerificationCallback;
+ return this.signers[0].SignatureCallback;
}
set {
foreach (ITamperProtectionChannelBindingElement signer in this.signers) {
- signer.SignatureVerificationCallback = value;
+ signer.SignatureCallback = value;
}
}
}
diff --git a/src/DotNetOAuth/ClassDiagram.cd b/src/DotNetOAuth/ClassDiagram.cd index d8baa13..5c33298 100644 --- a/src/DotNetOAuth/ClassDiagram.cd +++ b/src/DotNetOAuth/ClassDiagram.cd @@ -29,7 +29,7 @@ <Position X="6.5" Y="4.5" Width="4.75" />
<InheritanceLine Type="DotNetOAuth.ConsumerBase" FixedToPoint="true">
<Path>
- <Point X="8.875" Y="3.978" />
+ <Point X="8.875" Y="3.786" />
<Point X="8.875" Y="4.2" />
<Point X="8.125" Y="4.2" />
<Point X="8.125" Y="4.5" />
@@ -43,7 +43,7 @@ <Class Name="DotNetOAuth.ConsumerBase">
<Position X="6.5" Y="0.5" Width="4.75" />
<TypeIdentifier>
- <HashCode>ACAAAAAgAAABEAAAAAAABgAAAAAIAAQAAQAAAAAAABA=</HashCode>
+ <HashCode>ACAAAAAgAAABEAAAAAAABgAAAAAIAAAAAQAAAAAAABA=</HashCode>
<FileName>ConsumerBase.cs</FileName>
</TypeIdentifier>
</Class>
diff --git a/src/DotNetOAuth/ConsumerBase.cs b/src/DotNetOAuth/ConsumerBase.cs index 9b3b922..1cf5949 100644 --- a/src/DotNetOAuth/ConsumerBase.cs +++ b/src/DotNetOAuth/ConsumerBase.cs @@ -44,11 +44,6 @@ namespace DotNetOAuth { public string ConsumerKey { get; set; }
/// <summary>
- /// Gets or sets the Consumer Secret used to communicate with the Service Provider.
- /// </summary>
- public string ConsumerSecret { get; set; }
-
- /// <summary>
/// Gets the Service Provider that will be accessed.
/// </summary>
public ServiceProviderDescription ServiceProvider { get; private set; }
@@ -117,7 +112,6 @@ namespace DotNetOAuth { // Obtain an unauthorized request token.
var requestToken = new GetRequestTokenMessage(this.ServiceProvider.RequestTokenEndpoint) {
ConsumerKey = this.ConsumerKey,
- ConsumerSecret = this.ConsumerSecret,
};
requestToken.AddNonOAuthParameters(requestParameters);
var requestTokenResponse = this.Channel.Request<GrantRequestTokenMessage>(requestToken);
@@ -152,7 +146,6 @@ namespace DotNetOAuth { AccessToken = accessToken,
TokenSecret = this.TokenManager.GetTokenSecret(accessToken),
ConsumerKey = this.ConsumerKey,
- ConsumerSecret = this.ConsumerSecret,
};
return message;
@@ -169,7 +162,6 @@ namespace DotNetOAuth { RequestToken = requestToken,
TokenSecret = requestTokenSecret,
ConsumerKey = this.ConsumerKey,
- ConsumerSecret = this.ConsumerSecret,
};
var grantAccess = this.Channel.Request<GrantAccessTokenMessage>(requestAccess);
this.TokenManager.ExpireRequestTokenAndStoreNewAccessToken(this.ConsumerKey, requestToken, grantAccess.AccessToken, grantAccess.TokenSecret);
diff --git a/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs b/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs index b84b6e7..e00d206 100644 --- a/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs +++ b/src/DotNetOAuth/Messaging/ITamperProtectionChannelBindingElement.cs @@ -14,11 +14,10 @@ namespace DotNetOAuth.Messaging { /// </summary>
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.
- /// May be null for Consumers (who never have to verify signatures).
+ /// Gets or sets the delegate that will initialize the non-serialized properties necessary on a
+ /// signable message so that its signature can be correctly calculated or verified.
/// </summary>
- Action<ITamperResistantOAuthMessage> SignatureVerificationCallback { get; set; }
+ Action<ITamperResistantOAuthMessage> SignatureCallback { get; set; }
/// <summary>
/// Clones this instance.
|