summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-07-15 13:01:53 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-07-15 13:01:53 -0700
commit5f10f0446e50035bf1d357cdbbde0dc70305fe24 (patch)
tree92eda1cdfcf761979fa828c5d4f9f68b55c1f68b /src
parent025651f81ff3a1eee32f33aa7761f2bcfa7bbc71 (diff)
downloadDotNetOpenAuth-origin/Silverlight3.zip
DotNetOpenAuth-origin/Silverlight3.tar.gz
DotNetOpenAuth-origin/Silverlight3.tar.bz2
Added more source files.origin/Silverlight3
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuthSL.csproj19
-rw-r--r--src/DotNetOpenAuth/Messaging/Channel.cs31
-rw-r--r--src/DotNetOpenAuth/Messaging/ChannelContract.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/EmptyDictionary.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/EmptyList.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs14
-rw-r--r--src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingUtilities.cs5
-rw-r--r--src/DotNetOpenAuth/Messaging/NetworkDirectWebResponse.cs5
-rw-r--r--src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs16
-rw-r--r--src/DotNetOpenAuth/Messaging/UnprotectedMessageException.cs4
-rw-r--r--src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs6
12 files changed, 100 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj b/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
index 27e8ed8..fe7477c 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
@@ -74,10 +74,18 @@
<Compile Include="Loggers\ILog.cs" />
<Compile Include="Loggers\NoOpLogger.cs" />
<Compile Include="Messaging\CachedDirectWebResponse.cs" />
+ <Compile Include="Messaging\Channel.cs" />
+ <Compile Include="Messaging\ChannelContract.cs" />
+ <Compile Include="Messaging\ChannelEventArgs.cs" />
<Compile Include="Messaging\DirectWebRequestOptions.cs" />
+ <Compile Include="Messaging\EmptyDictionary.cs" />
+ <Compile Include="Messaging\EmptyEnumerator.cs" />
+ <Compile Include="Messaging\EmptyList.cs" />
+ <Compile Include="Messaging\EnumerableCache.cs" />
<Compile Include="Messaging\ErrorUtilities.cs" />
<Compile Include="Messaging\HostErrorException.cs" />
<Compile Include="Messaging\HttpDeliveryMethods.cs" />
+ <Compile Include="Messaging\IChannelBindingElement.cs" />
<Compile Include="Messaging\IDirectedProtocolMessage.cs" />
<Compile Include="Messaging\IDirectResponseProtocolMessage.cs" />
<Compile Include="Messaging\IDirectWebRequestHandler.cs">
@@ -86,16 +94,22 @@
<Compile Include="Messaging\IExtensionMessage.cs" />
<Compile Include="Messaging\IHttpDirectResponse.cs" />
<Compile Include="Messaging\IMessage.cs" />
+ <Compile Include="Messaging\IMessageFactory.cs" />
<Compile Include="Messaging\IMessageWithEvents.cs" />
<Compile Include="Messaging\IncomingWebResponse.cs" />
<Compile Include="Messaging\InternalErrorException.cs" />
<Compile Include="Messaging\IProtocolMessage.cs" />
+ <Compile Include="Messaging\IProtocolMessageWithExtensions.cs" />
+ <Compile Include="Messaging\ITamperResistantProtocolMessage.cs" />
+ <Compile Include="Messaging\KeyedCollectionDelegate.cs" />
<Compile Include="Messaging\MessagePartAttribute.cs" />
<Compile Include="Messaging\MessageProtections.cs" />
+ <Compile Include="Messaging\MessageReceivingEndpoint.cs" />
<Compile Include="Messaging\MessageSerializer.cs" />
<Compile Include="Messaging\MessageTransport.cs" />
<Compile Include="Messaging\MessagingStrings.Designer.cs" />
<Compile Include="Messaging\MessagingUtilities.cs" />
+ <Compile Include="Messaging\NetworkDirectWebResponse.cs" />
<Compile Include="Messaging\ProtocolException.cs" />
<Compile Include="Messaging\Reflection\IMessagePartEncoder.cs" />
<Compile Include="Messaging\Reflection\IMessagePartNullEncoder.cs" />
@@ -105,6 +119,8 @@
<Compile Include="Messaging\Reflection\MessagePart.cs" />
<Compile Include="Messaging\Reflection\ProtectionLevel.cs" />
<Compile Include="Messaging\Reflection\ValueMapping.cs" />
+ <Compile Include="Messaging\StandardWebRequestHandler.cs" />
+ <Compile Include="Messaging\UnprotectedMessageException.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Strings.Designer.cs" />
<Compile Include="Util.cs" />
@@ -145,6 +161,9 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Configuration\" />
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" Condition="" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs
index 0f307b5..301b5c7 100644
--- a/src/DotNetOpenAuth/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth/Messaging/Channel.cs
@@ -15,11 +15,13 @@ namespace DotNetOpenAuth.Messaging {
using System.IO;
using System.Linq;
using System.Net;
- using System.Net.Cache;
using System.Text;
using System.Threading;
- using System.Web;
using DotNetOpenAuth.Messaging.Reflection;
+#if !SILVERLIGHT
+ using System.Net.Cache;
+ using System.Web;
+#endif
/// <summary>
/// Manages sending direct messages to a remote party and receiving responses.
@@ -96,10 +98,12 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
private IMessageFactory messageTypeProvider;
+#if !SILVERLIGHT
/// <summary>
/// Backing store for the <see cref="CachePolicy"/> property.
/// </summary>
private RequestCachePolicy cachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
+#endif
/// <summary>
/// Initializes a new instance of the <see cref="Channel"/> class.
@@ -197,6 +201,7 @@ namespace DotNetOpenAuth.Messaging {
get { return this.messageTypeProvider; }
}
+#if !SILVERLIGHT
/// <summary>
/// Gets or sets the cache policy to use for direct message requests.
/// </summary>
@@ -377,6 +382,7 @@ namespace DotNetOpenAuth.Messaging {
return requestMessage;
}
+#endif
/// <summary>
/// Sends a direct message to a remote party and waits for the response.
@@ -436,6 +442,7 @@ namespace DotNetOpenAuth.Messaging {
#endregion
+#if !SILVERLIGHT
/// <summary>
/// Gets the current HTTP request being processed.
/// </summary>
@@ -451,6 +458,7 @@ namespace DotNetOpenAuth.Messaging {
return new HttpRequestInfo(HttpContext.Current.Request);
}
+#endif
/// <summary>
/// Checks whether a given HTTP method is expected to include an entity body in its request.
@@ -556,6 +564,7 @@ namespace DotNetOpenAuth.Messaging {
protected virtual void OnReceivingDirectResponse(IncomingWebResponse response, IDirectResponseProtocolMessage message) {
}
+#if !SILVERLIGHT
/// <summary>
/// Gets the protocol message that may be embedded in the given HTTP request.
/// </summary>
@@ -576,6 +585,7 @@ namespace DotNetOpenAuth.Messaging {
return (IDirectedProtocolMessage)this.Receive(fields, request.GetRecipient());
}
+#endif
/// <summary>
/// Deserializes a dictionary of values into a message.
@@ -605,6 +615,7 @@ namespace DotNetOpenAuth.Messaging {
return message;
}
+#if !SILVERLIGHT
/// <summary>
/// Queues an indirect message for transmittal via the user agent.
/// </summary>
@@ -697,6 +708,7 @@ namespace DotNetOpenAuth.Messaging {
return response;
}
+#endif
/// <summary>
/// Gets the protocol message that may be in the given HTTP response.
@@ -721,6 +733,7 @@ namespace DotNetOpenAuth.Messaging {
throw new NotImplementedException();
}
+#if !SILVERLIGHT
/// <summary>
/// Queues a message for sending in the response stream where the fields
/// are sent in the response stream in querystring style.
@@ -731,6 +744,7 @@ namespace DotNetOpenAuth.Messaging {
/// This method implements spec OAuth V1.0 section 5.3.
/// </remarks>
protected abstract OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response);
+#endif
/// <summary>
/// Prepares a message for transmit by applying signatures, nonces, etc.
@@ -832,7 +846,9 @@ namespace DotNetOpenAuth.Messaging {
var fields = messageAccessor.Serialize();
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(requestMessage.Recipient);
+#if !SILVERLIGHT
httpRequest.CachePolicy = this.CachePolicy;
+#endif
httpRequest.Method = "POST";
this.SendParametersInEntity(httpRequest, fields);
@@ -863,7 +879,11 @@ namespace DotNetOpenAuth.Messaging {
string requestBody = MessagingUtilities.CreateQueryString(fields);
byte[] requestBytes = PostEntityEncoding.GetBytes(requestBody);
+#if !SILVERLIGHT
httpRequest.ContentLength = requestBytes.Length;
+#else
+ httpRequest.Headers["Content-Length"] = requestBytes.Length.ToString(CultureInfo.InvariantCulture);
+#endif
Stream requestStream = this.WebRequestHandler.GetRequestStream(httpRequest);
try {
requestStream.Write(requestBytes, 0, requestBytes.Length);
@@ -996,7 +1016,12 @@ namespace DotNetOpenAuth.Messaging {
elements.Where(element => element.Protection != MessageProtections.None));
bool wasLastProtectionPresent = true;
- foreach (MessageProtections protectionKind in Enum.GetValues(typeof(MessageProtections))) {
+#if !SILVERLIGHT
+ IEnumerable<MessageProtections> availableProtections = Enum.GetValues(typeof(MessageProtections));
+#else
+ IEnumerable<MessageProtections> availableProtections = new MessageProtections[] { MessageProtections.All, MessageProtections.Expiration, MessageProtections.None, MessageProtections.ReplayProtection, MessageProtections.TamperProtection };
+#endif
+ foreach (MessageProtections protectionKind in availableProtections) {
if (protectionKind == MessageProtections.None) {
continue;
}
diff --git a/src/DotNetOpenAuth/Messaging/ChannelContract.cs b/src/DotNetOpenAuth/Messaging/ChannelContract.cs
index 551d7c4..95cbcdb 100644
--- a/src/DotNetOpenAuth/Messaging/ChannelContract.cs
+++ b/src/DotNetOpenAuth/Messaging/ChannelContract.cs
@@ -34,6 +34,7 @@ namespace DotNetOpenAuth.Messaging {
throw new NotImplementedException();
}
+#if !SILVERLIGHT
/// <summary>
/// Queues a message for sending in the response stream where the fields
/// are sent in the response stream in querystring style.
@@ -50,5 +51,6 @@ namespace DotNetOpenAuth.Messaging {
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
throw new NotImplementedException();
}
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/EmptyDictionary.cs b/src/DotNetOpenAuth/Messaging/EmptyDictionary.cs
index 22c947a..8a44a88 100644
--- a/src/DotNetOpenAuth/Messaging/EmptyDictionary.cs
+++ b/src/DotNetOpenAuth/Messaging/EmptyDictionary.cs
@@ -14,7 +14,9 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam>
/// <typeparam name="TValue">The type of the value.</typeparam>
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class EmptyDictionary<TKey, TValue> : IDictionary<TKey, TValue> {
/// <summary>
/// The singleton instance of the empty dictionary.
diff --git a/src/DotNetOpenAuth/Messaging/EmptyList.cs b/src/DotNetOpenAuth/Messaging/EmptyList.cs
index b418623..4e86afb 100644
--- a/src/DotNetOpenAuth/Messaging/EmptyList.cs
+++ b/src/DotNetOpenAuth/Messaging/EmptyList.cs
@@ -12,7 +12,9 @@ namespace DotNetOpenAuth.Messaging {
/// An empty, read-only list.
/// </summary>
/// <typeparam name="T">The type the list claims to include.</typeparam>
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class EmptyList<T> : IList<T> {
/// <summary>
/// The singleton instance of the empty list.
diff --git a/src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs
index 6cb27e6..d3a4ebe 100644
--- a/src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs
+++ b/src/DotNetOpenAuth/Messaging/HttpRequestInfo.cs
@@ -13,8 +13,10 @@ namespace DotNetOpenAuth.Messaging {
using System.Globalization;
using System.IO;
using System.Net;
+#if !SILVERLIGHT
using System.ServiceModel.Channels;
using System.Web;
+#endif
/// <summary>
/// A property store of details of an incoming HTTP request.
@@ -28,17 +30,29 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// The key/value pairs found in the entity of a POST request.
/// </summary>
+#if SILVERLIGHT
+ private Dictionary<string, string> form;
+#else
private NameValueCollection form;
+#endif
/// <summary>
/// The key/value pairs found in the querystring of the incoming request.
/// </summary>
+#if SILVERLIGHT
+ private Dictionary<string, string> queryString;
+#else
private NameValueCollection queryString;
+#endif
/// <summary>
/// Backing field for the <see cref="QueryStringBeforeRewriting"/> property.
/// </summary>
+#if SILVERLIGHT
+ private Dictionary<string, string> queryStringBeforeRewriting;
+#else
private NameValueCollection queryStringBeforeRewriting;
+#endif
/// <summary>
/// Backing field for the <see cref="Message"/> property.
diff --git a/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs b/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs
index 16786e3..55bf3c1 100644
--- a/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs
+++ b/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs
@@ -15,7 +15,9 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam>
/// <typeparam name="TItem">The type of the item.</typeparam>
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class KeyedCollectionDelegate<TKey, TItem> : KeyedCollection<TKey, TItem> {
/// <summary>
/// The delegate that returns a key for the given item.
diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
index 43cfbb7..ec34d25 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
@@ -19,10 +19,11 @@ namespace DotNetOpenAuth.Messaging {
#if !SILVERLIGHT
using System.Web;
using System.Web.Mvc;
+#else
+ using System.Windows.Browser;
#endif
using DotNetOpenAuth.Messaging.Reflection;
- using System.Windows.Browser;
-using System.Globalization;
+ using System.Globalization;
/// <summary>
/// A grab-bag of utility methods useful for the channel stack of the protocol.
diff --git a/src/DotNetOpenAuth/Messaging/NetworkDirectWebResponse.cs b/src/DotNetOpenAuth/Messaging/NetworkDirectWebResponse.cs
index 2ee7feb..193cafa 100644
--- a/src/DotNetOpenAuth/Messaging/NetworkDirectWebResponse.cs
+++ b/src/DotNetOpenAuth/Messaging/NetworkDirectWebResponse.cs
@@ -61,7 +61,12 @@ namespace DotNetOpenAuth.Messaging {
throw new ObjectDisposedException(GetType().Name);
}
+#if !SILVERLIGHT
string contentEncoding = this.Headers[HttpResponseHeader.ContentEncoding];
+#else
+ string contentEncoding = this.Headers["Content-Encoding"];
+#endif
+
if (string.IsNullOrEmpty(contentEncoding)) {
return new StreamReader(this.ResponseStream);
} else {
diff --git a/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs b/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs
index cc991cd..b70338a 100644
--- a/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs
+++ b/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs
@@ -127,10 +127,16 @@ namespace DotNetOpenAuth.Messaging {
try {
Logger.Http.DebugFormat("HTTP {0} {1}", request.Method, request.RequestUri);
+#if !SILVERLIGHT
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+#else
+ var async = request.BeginGetResponse(null, null);
+ HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(async);
+#endif
return new NetworkDirectWebResponse(request.RequestUri, response);
} catch (WebException ex) {
HttpWebResponse response = (HttpWebResponse)ex.Response;
+#if !SILVERLIGHT
if (response != null && response.StatusCode == HttpStatusCode.ExpectationFailed &&
request.ServicePoint.Expect100Continue) {
// Some OpenID servers doesn't understand the Expect header and send 417 error back.
@@ -147,6 +153,7 @@ namespace DotNetOpenAuth.Messaging {
// but we'd have to set it BEFORE each request.
////request.Expect = "";
}
+#endif
if ((options & DirectWebRequestOptions.AcceptAllHttpResponses) != 0 && response != null &&
response.StatusCode != HttpStatusCode.ExpectationFailed) {
@@ -215,8 +222,13 @@ namespace DotNetOpenAuth.Messaging {
PrepareRequest(request, true);
try {
+#if !SILVERLIGHT
return request.GetRequestStream();
- } catch (SocketException ex) {
+#else
+ var async = request.BeginGetRequestStream(null, null);
+ return request.EndGetRequestStream(async);
+#endif
+ } catch (SocketException ex) {
throw ErrorUtilities.Wrap(ex, MessagingStrings.WebRequestFailed, request.RequestUri);
} catch (WebException ex) {
throw ErrorUtilities.Wrap(ex, MessagingStrings.WebRequestFailed, request.RequestUri);
@@ -233,11 +245,13 @@ namespace DotNetOpenAuth.Messaging {
// Be careful to not try to change the HTTP headers that have already gone out.
if (preparingPost || request.Method == "GET") {
+#if !SILVERLIGHT
// Some sites, such as Technorati, return 403 Forbidden on identity
// pages unless a User-Agent header is included.
if (string.IsNullOrEmpty(request.UserAgent)) {
request.UserAgent = userAgentValue;
}
+#endif
}
}
}
diff --git a/src/DotNetOpenAuth/Messaging/UnprotectedMessageException.cs b/src/DotNetOpenAuth/Messaging/UnprotectedMessageException.cs
index 2f21184..6c85711 100644
--- a/src/DotNetOpenAuth/Messaging/UnprotectedMessageException.cs
+++ b/src/DotNetOpenAuth/Messaging/UnprotectedMessageException.cs
@@ -11,7 +11,9 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// An exception thrown when messages cannot receive all the protections they require.
/// </summary>
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class UnprotectedMessageException : ProtocolException {
/// <summary>
/// Initializes a new instance of the <see cref="UnprotectedMessageException"/> class.
@@ -22,6 +24,7 @@ namespace DotNetOpenAuth.Messaging {
: base(string.Format(CultureInfo.CurrentCulture, MessagingStrings.InsufficientMessageProtection, faultedMessage.GetType().Name, faultedMessage.RequiredProtection, appliedProtection), faultedMessage) {
}
+#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the <see cref="UnprotectedMessageException"/> class.
/// </summary>
@@ -33,5 +36,6 @@ namespace DotNetOpenAuth.Messaging {
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs b/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs
index 733b698..1836914 100644
--- a/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs
+++ b/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs
@@ -12,10 +12,12 @@ namespace DotNetOpenAuth.Messaging {
using System.Globalization;
using System.IO;
using System.Net;
- using System.Net.Cache;
using System.Text.RegularExpressions;
- using DotNetOpenAuth.Configuration;
using DotNetOpenAuth.Messaging;
+#if !SILVERLIGHT
+ using System.Net.Cache;
+ using DotNetOpenAuth.Configuration;
+#endif
/// <summary>
/// A paranoid HTTP get/post request engine. It helps to protect against attacks from remote