Просмотр исходного кода

2009-03-04 Atsushi Enomoto <[email protected]>

	* CrossDomainAccessManager.cs : replace reflection-based
	  Uri retrieval with actually working one.

	* HttpRequestChannel.cs : use cross domain access manager.


svn path=/trunk/mcs/; revision=128581
Atsushi Eno 17 лет назад
Родитель
Сommit
dfd1716b11

+ 4 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog

@@ -1,3 +1,7 @@
+2009-03-04  Atsushi Enomoto  <[email protected]>
+
+	* HttpRequestChannel.cs : use cross domain access manager.
+
 2009-02-27  Atsushi Enomoto  <[email protected]>
 
 	* Message.cs : (in CreateBufferedCopy) do not pass the entire

+ 8 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs

@@ -128,6 +128,14 @@ namespace System.ServiceModel.Channels
 #if !NET_2_1
 				web_request.ContentLength = (int) buffer.Length;
 #endif
+
+#if NET_2_1
+				// We can verify cross domain access policy 
+				// with full set of headers and target URL.
+				if (!CrossDomainAccessManager.Current.IsAllowed (destination, web_request.Headers.AllKeys))
+					throw new InvalidOperationException (String.Format ("Cross domain web service access to {0} is not allowed", destination));
+#endif
+
 				Stream requestStream = web_request.EndGetRequestStream (web_request.BeginGetRequestStream (null, null));
 				requestStream.Write (buffer.GetBuffer (), 0, (int) buffer.Length);
 				requestStream.Close ();

+ 5 - 0
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog

@@ -1,3 +1,8 @@
+2009-03-04  Atsushi Enomoto  <[email protected]>
+
+	* CrossDomainAccessManager.cs : replace reflection-based
+	  Uri retrieval with actually working one.
+
 2009-03-04  Atsushi Enomoto  <[email protected]>
 
 	* CrossDomainAccessManager.cs : 2.1 WebRequest misses some

+ 6 - 6
mcs/class/System.ServiceModel/System.ServiceModel/CrossDomainAccessManager.cs

@@ -65,16 +65,16 @@ namespace System.ServiceModel
 
 		static Uri GetApplicationDocumentUri ()
 		{
-			var assembly = Assembly.Load ("System.Windows.Browser, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
+			var assembly = Assembly.Load ("System.Windows, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
 			if (assembly == null)
-				throw new InvalidOperationException ("Can not load System.Windows.Browser");
+				throw new InvalidOperationException ("Can not load System.Windows.dll");
 
-			var type = assembly.GetType ("System.Windows.Browser.HtmlPage");
+			var type = assembly.GetType ("System.Windows.Interop.PluginHost");
 			if (type == null)
 				throw new InvalidOperationException ("Can not get HtmlPage");
 
-			object document = type.GetProperty ("Document").GetValue (null, null);
-			return (Uri) document.GetType ().GetProperty ("DocumentUri").GetValue (document, null);
+			var prop = type.GetProperty ("RootUri");
+			return (Uri) prop.GetValue (null, null);
 		}
 
 		public static CrossDomainAccessManager CreateForUri (Uri applicationUri)
@@ -130,7 +130,6 @@ namespace System.ServiceModel
 
 		public bool IsAllowed (Uri uri, params string [] headerKeys)
 		{
-
 			if (uri.Host == ApplicationUri.Host)
 				return true;
 
@@ -144,6 +143,7 @@ namespace System.ServiceModel
 			}
 			else if (Domain != null) {
 			}
+Console.WriteLine ("##### Cross Domain Access Manager rejected '{0}' with headers {1}", uri, String.Join (",", headerKeys));
 			return false;
 		}
 	}