-Subproject commit fd9e7e3ba7848fedf4a5e6a3bb08d91de8f9df32
+Subproject commit 9103ec71e245dd3002a3c1190ee1acb4f1c8bcba
+++ /dev/null
-//
-// System.Net.NetworkInformation.NetworkChange
-//
-// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (c) 2006, 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-#if MOBILE
-using System.Runtime.InteropServices;
-
-namespace System.Net.NetworkInformation {
- public abstract class NetworkChange {
- internal delegate void NetworkStateChangedCallback (IntPtr sender, IntPtr data);
- static NetworkChange ()
- {
- state_changed_callback = new NetworkStateChangedCallback (StateChangedCallback);
- _moonlight_cbinding_moon_network_service_set_network_state_changed_callback (_moonlight_cbinding_runtime_get_network_service(),
- state_changed_callback,
- IntPtr.Zero);
- }
-
- static NetworkStateChangedCallback state_changed_callback;
-
- static void StateChangedCallback (IntPtr sender, IntPtr data)
- {
- try {
- NetworkAddressChangedEventHandler h = NetworkAddressChanged;
- if (h != null)
- h (null, EventArgs.Empty);
- } catch (Exception ex) {
- try {
- Console.WriteLine ("Unhandled exception: {0}", ex);
- } catch {
- // Ignore
- }
- }
- }
-
- protected NetworkChange ()
- {
- }
-
- public static event NetworkAddressChangedEventHandler NetworkAddressChanged;
-
- [DllImport ("moon")]
- internal extern static IntPtr _moonlight_cbinding_runtime_get_network_service ();
-
- [DllImport ("moon")]
- internal extern static void _moonlight_cbinding_moon_network_service_set_network_state_changed_callback (IntPtr service,
- NetworkStateChangedCallback handler, IntPtr data);
-
- [DllImport ("moon")]
- internal extern static bool _moonlight_cbinding_moon_network_service_get_is_network_available (IntPtr service);
- }
-}
-#endif
-
+++ /dev/null
-//
-// System.Net.NetworkInformation.NetworkInterface
-//
-// Authors:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-// Atsushi Enomoto (atsushi@ximian.com)
-// Miguel de Icaza (miguel@novell.com)
-// Eric Butler (eric@extremeboredom.net)
-// Marek Habersack (mhabersack@novell.com)
-//
-// Copyright (c) 2006-2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.NetworkInformation {
-
- public abstract class NetworkInterface {
-
- protected NetworkInterface ()
- {
- }
-
- public static bool GetIsNetworkAvailable ()
- {
- return NetworkChange._moonlight_cbinding_moon_network_service_get_is_network_available (NetworkChange._moonlight_cbinding_runtime_get_network_service ());
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// BaseDomainPolicy.cs
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-// Base class for shared stuff between the Silverlight and Flash policies
-// e.g. Headers and Domain comparison
-
-namespace System.Net.Policy {
-
- abstract class BaseDomainPolicy : ICrossDomainPolicy {
-
- static string root;
- static Uri app;
-#if !TEST
- static BaseDomainPolicy ()
- {
- ApplicationUri = new Uri (AppDomain.CurrentDomain.GetData ("xap_uri") as string);
- }
-#endif
- static public Uri ApplicationUri {
- get { return app; }
- set {
- app = value;
- root = null;
- }
- }
-
- static public string ApplicationRoot {
- get {
- if (root == null)
- root = CrossDomainPolicyManager.GetRoot (ApplicationUri);
- return root;
- }
- }
-
- public class Headers {
-
- sealed class PrefixComparer : IEqualityComparer<string> {
-
- public bool Equals (string x, string y)
- {
- int check_length = x.Length - 1;
- if ((x.Length > 0) && (x [check_length] == '*'))
- return (String.Compare (x, 0, y, 0, check_length, StringComparison.OrdinalIgnoreCase) == 0);
-
- return (String.Compare (x, y, StringComparison.OrdinalIgnoreCase) == 0);
- }
-
- public int GetHashCode (string obj)
- {
- return (obj == null) ? 0 : obj.GetHashCode ();
- }
- }
-
- static PrefixComparer pc = new PrefixComparer ();
-
- private List<string> list;
-
- public Headers ()
- {
- }
-
- public bool AllowAllHeaders { get; private set; }
-
- public bool IsAllowed (string[] headers)
- {
- if (AllowAllHeaders)
- return true;
-
- if (headers == null || headers.Length == 0)
- return true;
-
- return headers.All (s => list.Contains (s, pc));
- }
-
- public void SetHeaders (string raw)
- {
- if (raw == "*") {
- AllowAllHeaders = true;
- list = null;
- } else if (raw != null) {
- string [] headers = raw.Split (',');
- list = new List<string> (headers.Length + 1);
- list.Add ("Content-Type");
- for (int i = 0; i < headers.Length; i++) {
- string s = headers [i].Trim ();
- if (!String.IsNullOrEmpty (s))
- list.Add (s);
- }
- } else {
- // without a specified 'http-request-headers' no header, expect Content-Type, is allowed
- AllowAllHeaders = false;
- list = new List<string> (1);
- list.Add ("Content-Type");
- }
- }
- }
-
- abstract public bool IsAllowed (WebRequest request);
-
- public Exception Exception {
- get; internal set;
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// ClientAccessPolicy.cs
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace System.Net.Policy {
-
- partial class ClientAccessPolicy : BaseDomainPolicy {
-
- public class AccessPolicy {
-
- public const short MinPort = 4502;
- public const short MaxPort = 4534;
-
- public List<AllowFrom> AllowedServices { get; private set; }
- public List<GrantTo> GrantedResources { get; private set; }
- public long PortMask { get; set; }
-
- public AccessPolicy ()
- {
- AllowedServices = new List<AllowFrom> ();
- GrantedResources = new List<GrantTo> ();
- }
-
- public bool PortAllowed (int port)
- {
- if ((port < MinPort) || (port > MaxPort))
- return false;
-
- return (((PortMask >> (port - MinPort)) & 1) == 1);
- }
- }
-
- public ClientAccessPolicy ()
- {
- AccessPolicyList = new List<AccessPolicy> ();
- }
-
- public List<AccessPolicy> AccessPolicyList { get; private set; }
-
- public bool IsAllowed (IPEndPoint endpoint)
- {
- foreach (AccessPolicy policy in AccessPolicyList) {
- // does something allow our URI in this policy ?
- foreach (AllowFrom af in policy.AllowedServices) {
- // fake "GET" as method as this does not apply to sockets
- if (af.IsAllowed (ApplicationUri, "GET")) {
- // if so, is our request port allowed ?
- if (policy.PortAllowed (endpoint.Port))
- return true;
- }
- }
- }
- // no policy allows this socket connection
- return false;
- }
-
- // note: tests show that it only applies to Silverlight policy (seems to work with Flash)
- // and only if we're not granting full access (i.e. '/' with all subpaths)
- // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=466043
- private bool CheckOriginalPath (Uri uri)
- {
- // Path Restriction for cross-domain requests
- // http://msdn.microsoft.com/en-us/library/cc838250(VS.95).aspx
- string original = uri.OriginalString;
- // applies to the *path* only (not the query part)
- int query = original.IndexOf ('?');
- if (query != -1)
- original = original.Substring (0, query);
-
- if (original.Contains ('%') || original.Contains ("./") || original.Contains ("..")) {
- // special case when no path restriction applies - i.e. the above characters are accepted by SL
- if (AccessPolicyList.Count != 1)
- return false;
- AccessPolicy policy = AccessPolicyList [0];
- if (policy.GrantedResources.Count != 1)
- return false;
- GrantTo gt = policy.GrantedResources [0];
- if (gt.Resources.Count != 1)
- return false;
- Resource r = gt.Resources [0];
- return (r.IncludeSubpaths && (r.Path == "/"));
- }
- return true;
- }
-
- public override bool IsAllowed (WebRequest request)
- {
- return IsAllowed (request.RequestUri, request.Method, request.Headers.AllKeys);
- }
-
- public bool IsAllowed (Uri uri, string method, params string [] headerKeys)
- {
- foreach (AccessPolicy policy in AccessPolicyList) {
- // does something allow our URI in this policy ?
- foreach (AllowFrom af in policy.AllowedServices) {
- // is the application (XAP) URI allowed by the policy ?
- // check headers
- if (!af.HttpRequestHeaders.IsAllowed (headerKeys)) {
- return false;
- }
-
- if (af.IsAllowed (ApplicationUri, method)) {
- foreach (GrantTo gt in policy.GrantedResources) {
- // is the requested access to the Uri granted under this policy ?
- if (gt.IsGranted (uri)) {
- // at this stage the URI has removed the "offending" characters so
- // we need to look at the original
- return CheckOriginalPath (uri);
- }
- }
- }
- }
- }
- // no policy allows this web connection
- return false;
- }
-
- public class AllowFrom {
-
- public AllowFrom ()
- {
- Domains = new List<string> ();
- HttpRequestHeaders = new Headers ();
- }
-
- public bool AllowAnyDomain { get; set; }
-
- public List<string> Domains { get; private set; }
-
- public Headers HttpRequestHeaders { get; private set; }
-
- public bool AllowAnyMethod { get; set; }
-
- public bool IsAllowed (Uri uri, string method)
- {
- // check methods
- if (!AllowAnyMethod) {
- // if not all methods are allowed (*) then only GET and POST request are possible
- // further restriction exists in the Client http stack
- if ((String.Compare (method, "GET", StringComparison.OrdinalIgnoreCase) != 0) &&
- (String.Compare (method, "POST", StringComparison.OrdinalIgnoreCase) != 0)) {
- return false;
- }
- }
-
- // check domains
- if (AllowAnyDomain)
- return true;
-
- if (Domains.All (domain => !CheckDomainUri (uri, domain)))
- return false;
- return true;
- }
-
- const string AllHttpScheme = "http://*";
- const string AllHttpsScheme = "https://*";
- const string AllFileScheme = "file:///";
-
- static bool CheckDomainUri (Uri applicationUri, string policy)
- {
- Uri uri;
- if (Uri.TryCreate (policy, UriKind.Absolute, out uri)) {
- // if no local path is part of the policy domain then we compare to the root
- if (uri.LocalPath == "/")
- return (uri.ToString () == ApplicationRoot);
- // otherwise the path must match
- if (uri.LocalPath != ApplicationUri.LocalPath)
- return false;
- return (CrossDomainPolicyManager.GetRoot (uri) == ApplicationRoot);
- }
-
- // SL policies supports a * wildcard at the start of their host name (but not elsewhere)
-
- // check for matching protocol
- if (!policy.StartsWith (ApplicationUri.Scheme))
- return false;
-
- switch (ApplicationUri.Scheme) {
- case "http":
- if (policy == AllHttpScheme)
- return (applicationUri.Port == 80);
- break;
- case "https":
- if (policy == AllHttpsScheme)
- return (applicationUri.Port == 443);
- break;
- case "file":
- if (policy == AllFileScheme)
- return true;
- break;
- }
-
- if (policy.IndexOf ("://*.", ApplicationUri.Scheme.Length) != ApplicationUri.Scheme.Length)
- return false;
- // remove *. from uri
- policy = policy.Remove (ApplicationUri.Scheme.Length + 3, 2);
- // create Uri - without the *. it should be a valid one
- if (!Uri.TryCreate (policy, UriKind.Absolute, out uri))
- return false;
- // path must be "empty" and query and fragment (really) empty
- if ((uri.LocalPath != "/") || !String.IsNullOrEmpty (uri.Query) || !String.IsNullOrEmpty (uri.Fragment))
- return false;
- // port must match
- if (ApplicationUri.Port != uri.Port)
- return false;
- // the application uri host must end with the policy host name
- return ApplicationUri.DnsSafeHost.EndsWith (uri.DnsSafeHost);
- }
- }
-
- public class GrantTo
- {
- public GrantTo ()
- {
- Resources = new List<Resource> ();
- }
-
- public List<Resource> Resources { get; private set; }
-
- public bool IsGranted (Uri uri)
- {
- foreach (var gr in Resources) {
- if (gr.IncludeSubpaths) {
- string granted = gr.Path;
- string local = uri.LocalPath;
- if (local.StartsWith (granted, StringComparison.Ordinal)) {
- // "/test" equals "/test" and "test/xyx" but not "/test2"
- // "/test/" equals "test/xyx" but not "/test" or "/test2"
- if (local.Length == granted.Length)
- return true;
- else if (granted [granted.Length - 1] == '/')
- return true;
- else if (local [granted.Length] == '/')
- return true;
- }
- } else {
- if (uri.LocalPath == gr.Path)
- return true;
- }
- }
- return false;
- }
- }
-
- public class Resource {
- private string path;
-
- public string Path {
- get { return path; }
- set {
- // an empty Path Ressource makes the *whole* policy file invalid
- if (String.IsNullOrEmpty (value))
- throw new NotSupportedException ();
- path = value;
- }
- }
-
- public bool IncludeSubpaths { get; set; }
- }
- }
-}
-
-#endif
-
-
+++ /dev/null
-//
-// ClientAccessPolicyParser.cs
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Xml;
-
-/*
-default namespace = ""
-
-grammar {
-
-start = access-policy
-
-access-policy = element access-policy {
- element cross-domain-access {
- element policy { allow-from, grant-to }
- }
-}
-
-allow-from = element allow-from {
- attribute http-request-headers { text },
- element domain {
- attribute uri { text }
- }
-}
-
-grant-to = element grant-to {
- (resource | socket-resource)+
-}
-
-resource = element resource {
- attribute path { text },
- attribute include-subpaths { "true" | "false" }
-}
-
-socket-resource = element socket-resource {
- attribute port { text },
- attribute protocol { text }
-}
-
-}
-*/
-
-namespace System.Net.Policy {
-
- partial class ClientAccessPolicy {
-
- static bool IsNonElement (XmlReader reader)
- {
- return (reader.NodeType != XmlNodeType.Element);
- }
-
- static bool IsNonEmptyElement (XmlReader reader)
- {
- return (reader.IsEmptyElement || IsNonElement (reader));
- }
-
- static public ICrossDomainPolicy FromStream (Stream stream)
- {
- ClientAccessPolicy cap = new ClientAccessPolicy ();
-
- // Silverlight accepts whitespaces before the XML - which is invalid XML
- StreamReader sr = new StreamReader (stream);
- while (Char.IsWhiteSpace ((char) sr.Peek ()))
- sr.Read ();
-
- XmlReaderSettings policy_settings = new XmlReaderSettings ();
- policy_settings.DtdProcessing = DtdProcessing.Ignore;
- using (XmlReader reader = XmlReader.Create (sr, policy_settings)) {
- reader.MoveToContent ();
- if (reader.IsEmptyElement) {
- reader.Skip ();
- return null;
- }
- reader.ReadStartElement ("access-policy", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (IsNonEmptyElement (reader) || (reader.LocalName != "cross-domain-access")) {
- reader.Skip ();
- continue;
- }
-
- reader.ReadStartElement ("cross-domain-access", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (IsNonEmptyElement (reader) || (reader.Name != "policy")) {
- reader.Skip ();
- continue;
- }
-
- ReadPolicyElement (reader, cap);
- }
- reader.ReadEndElement ();
- }
- reader.ReadEndElement ();
- }
- return cap;
- }
-
- static void ReadPolicyElement (XmlReader reader, ClientAccessPolicy cap)
- {
- if (reader.HasAttributes || reader.IsEmptyElement) {
- reader.Skip ();
- return;
- }
-
- var policy = new AccessPolicy ();
- bool valid = true;
-
- reader.ReadStartElement ("policy", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (IsNonElement (reader)) {
- reader.Skip ();
- continue;
- }
-
- switch (reader.LocalName) {
- case "allow-from":
- ReadAllowFromElement (reader, policy);
- break;
- case "grant-to":
- ReadGrantToElement (reader, policy);
- break;
- default:
- valid = false;
- reader.Skip ();
- break;
- }
- }
-
- if (valid)
- cap.AccessPolicyList.Add (policy);
- reader.ReadEndElement ();
- }
-
- static void ReadAllowFromElement (XmlReader reader, AccessPolicy policy)
- {
- if (IsNonEmptyElement (reader)) {
- reader.Skip ();
- return;
- }
-
- bool valid = true;
- string headers = null;
- string methods = null; // new in SL3
- if (reader.HasAttributes) {
- int n = reader.AttributeCount;
- headers = reader.GetAttribute ("http-request-headers");
- if (headers != null)
- n--;
- methods = reader.GetAttribute ("http-methods");
- if (methods != null)
- n--;
- valid = (n == 0);
- }
-
- var v = new AllowFrom ();
- v.HttpRequestHeaders.SetHeaders (headers);
- v.AllowAnyMethod = (methods == "*"); // only legal value defined, otherwise restricted to GET and POST
- reader.ReadStartElement ("allow-from", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (IsNonElement (reader) || !String.IsNullOrEmpty (reader.NamespaceURI)) {
- reader.Skip ();
- continue;
- }
- switch (reader.LocalName) {
- case "domain":
- var d = reader.GetAttribute ("uri");
- if (d == "*")
- v.AllowAnyDomain = true;
- else
- v.Domains.Add (d);
- reader.Skip ();
- break;
- default:
- valid = false;
- reader.Skip ();
- continue;
- }
- }
- if (valid)
- policy.AllowedServices.Add (v);
- reader.ReadEndElement ();
- }
-
- // only "path" and "include-subpaths" attributes are allowed - anything else is not considered
- static Resource CreateResource (XmlReader reader)
- {
- int n = reader.AttributeCount;
- string path = reader.GetAttribute ("path");
- if (path != null)
- n--;
- string subpaths = reader.GetAttribute ("include-subpaths");
- if (subpaths != null)
- n--;
- if ((n != 0) || !reader.IsEmptyElement)
- return null;
-
- return new Resource () {
- Path = path,
- IncludeSubpaths = subpaths == null ? false : XmlConvert.ToBoolean (subpaths)
- };
- }
-
- static void ReadGrantToElement (XmlReader reader, AccessPolicy policy)
- {
- var v = new GrantTo ();
- bool valid = true;
-
- if (reader.HasAttributes || reader.IsEmptyElement) {
- reader.Skip ();
- return;
- }
-
- reader.ReadStartElement ("grant-to", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (IsNonElement (reader) || !String.IsNullOrEmpty (reader.NamespaceURI)) {
- reader.Skip ();
- continue;
- }
-
- switch (reader.LocalName) {
- case "resource":
- var r = CreateResource (reader);
- if (r == null)
- valid = false;
- else
- v.Resources.Add (r);
- break;
- case "socket-resource":
- // ignore everything that is not TCP
- if (reader.GetAttribute ("protocol") != "tcp")
- break;
- // we can merge them all together inside a policy
- policy.PortMask |= ParsePorts (reader.GetAttribute ("port"));
- break;
- default:
- valid = false;
- break;
- }
- reader.Skip ();
- }
- if (valid)
- policy.GrantedResources.Add (v);
- reader.ReadEndElement ();
- }
-
- // e.g. reserved ? 4534-4502
- static long ParsePorts (string ports)
- {
- long mask = 0;
- int sep = ports.IndexOf ('-');
- if (sep >= 0) {
- // range
- ushort from = ParsePort (ports.Substring (0, sep));
- ushort to = ParsePort (ports.Substring (sep + 1));
- for (int port = from; port <= to; port++)
- mask |= (long) (1ul << (port - AccessPolicy.MinPort));
- } else {
- // single
- ushort port = ParsePort (ports);
- mask |= (long) (1ul << (port - AccessPolicy.MinPort));
- }
- return mask;
- }
-
- static ushort ParsePort (string s)
- {
- ushort port;
- if (!UInt16.TryParse (s, out port) || (port < AccessPolicy.MinPort) || (port > AccessPolicy.MaxPort))
- throw new XmlException ("Invalid port");
- return port;
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// CrossDomainPolicyManager.cs
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net.Sockets;
-using System.Reflection;
-using System.Security;
-using System.Text;
-using System.Threading;
-
-namespace System.Net.Policy {
-
- internal static class CrossDomainPolicyManager {
-
- public static string GetRoot (Uri uri)
- {
- if ((uri.Scheme == "http" && uri.Port == 80) || (uri.Scheme == "https" && uri.Port == 443) || (uri.Port == -1))
- return String.Format ("{0}://{1}/", uri.Scheme, uri.DnsSafeHost);
- else
- return String.Format ("{0}://{1}:{2}/", uri.Scheme, uri.DnsSafeHost, uri.Port);
- }
-#if !TEST
- public const string ClientAccessPolicyFile = "/clientaccesspolicy.xml";
- public const string CrossDomainFile = "/crossdomain.xml";
-
- const int Timeout = 10000;
-
- // Web Access Policy
-
- static Dictionary<string,ICrossDomainPolicy> policies = new Dictionary<string,ICrossDomainPolicy> ();
-
- static internal ICrossDomainPolicy PolicyDownloadPolicy = new PolicyDownloadPolicy ();
- static ICrossDomainPolicy site_of_origin_policy = new SiteOfOriginPolicy ();
- static ICrossDomainPolicy no_access_policy = new NoAccessPolicy ();
-
- static Uri GetRootUri (Uri uri)
- {
- return new Uri (GetRoot (uri));
- }
-
- public static Uri GetSilverlightPolicyUri (Uri uri)
- {
- return new Uri (GetRootUri (uri), CrossDomainPolicyManager.ClientAccessPolicyFile);
- }
-
- public static Uri GetFlashPolicyUri (Uri uri)
- {
- return new Uri (GetRootUri (uri), CrossDomainPolicyManager.CrossDomainFile);
- }
-
- public static ICrossDomainPolicy GetCachedWebPolicy (Uri uri)
- {
- // if we request an Uri from the same site then we return an "always positive" policy
- if (SiteOfOriginPolicy.HasSameOrigin (uri, BaseDomainPolicy.ApplicationUri))
- return site_of_origin_policy;
-
- // otherwise we search for an already downloaded policy for the web site
- string root = GetRoot (uri);
- ICrossDomainPolicy policy = null;
- policies.TryGetValue (root, out policy);
- // and we return it (if we have it) or null (if we dont)
- return policy;
- }
-
- private static void AddPolicy (Uri responseUri, ICrossDomainPolicy policy)
- {
- string root = GetRoot (responseUri);
- policies [root] = policy;
- }
-
- // see moon/test/2.0/WebPolicies/Pages.xaml.cs for all test cases
- private static bool CheckContentType (string contentType)
- {
- const string application_xml = "application/xml";
-
- // most common case: all text/* are accepted
- if (contentType.StartsWith ("text/"))
- return true;
-
- // special case (e.g. used in nbcolympics)
- if (contentType.StartsWith (application_xml)) {
- if (application_xml.Length == contentType.Length)
- return true; // exact match
-
- // e.g. "application/xml; charset=x" - we do not care what comes after ';'
- if (contentType.Length > application_xml.Length)
- return contentType [application_xml.Length] == ';';
- }
- return false;
- }
-
- public static ICrossDomainPolicy BuildSilverlightPolicy (HttpWebResponse response)
- {
- // return null if no Silverlight policy was found, since we offer a second chance with a flash policy
- if ((response.StatusCode != HttpStatusCode.OK) || !CheckContentType (response.ContentType))
- return null;
-
- ICrossDomainPolicy policy = null;
- try {
- policy = ClientAccessPolicy.FromStream (response.GetResponseStream ());
- if (policy != null)
- AddPolicy (response.ResponseUri, policy);
- } catch (Exception ex) {
- Console.WriteLine (String.Format ("CrossDomainAccessManager caught an exception while reading {0}: {1}",
- response.ResponseUri, ex));
- // and ignore.
- }
- return policy;
- }
-
- public static ICrossDomainPolicy BuildFlashPolicy (HttpWebResponse response)
- {
- ICrossDomainPolicy policy = null;
- if ((response.StatusCode == HttpStatusCode.OK) && CheckContentType (response.ContentType)) {
- try {
- policy = FlashCrossDomainPolicy.FromStream (response.GetResponseStream ());
- } catch (Exception ex) {
- Console.WriteLine (String.Format ("CrossDomainAccessManager caught an exception while reading {0}: {1}",
- response.ResponseUri, ex));
- // and ignore.
- }
- if (policy != null) {
- // see DRT# 864 and 865
- string site_control = response.InternalHeaders ["X-Permitted-Cross-Domain-Policies"];
- if (!String.IsNullOrEmpty (site_control))
- (policy as FlashCrossDomainPolicy).SiteControl = site_control;
- }
- }
-
- // the flash policy was the last chance, keep a NoAccess into the cache
- if (policy == null)
- policy = no_access_policy;
-
- AddPolicy (response.ResponseUri, policy);
- return policy;
- }
-
- // Socket Policy
- //
- // - we connect once to a site for the entire application life time
- // - this returns us a policy file (silverlight format only) or else no access is granted
- // - this policy file
- // - can contain multiple policies
- // - can apply to multiple domains
- // - can grant access to several resources
-
- static Dictionary<string,ClientAccessPolicy> socket_policies = new Dictionary<string,ClientAccessPolicy> ();
- static byte [] socket_policy_file_request = Encoding.UTF8.GetBytes ("<policy-file-request/>");
- const int PolicyPort = 943;
-
- static Stream GetPolicyStream (IPEndPoint endpoint)
- {
- MemoryStream ms = new MemoryStream ();
- ManualResetEvent mre = new ManualResetEvent (false);
- // Silverlight only support TCP
- Socket socket = new Socket (endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
-
- // Application code can't connect to port 943, so we need a special/internal API/ctor to allow this
- SocketAsyncEventArgs saea = new SocketAsyncEventArgs (true);
- saea.RemoteEndPoint = new IPEndPoint (endpoint.Address, PolicyPort);
- saea.Completed += delegate (object sender, SocketAsyncEventArgs e) {
- if (e.SocketError != SocketError.Success) {
- mre.Set ();
- return;
- }
-
- switch (e.LastOperation) {
- case SocketAsyncOperation.Connect:
- e.SetBuffer (socket_policy_file_request, 0, socket_policy_file_request.Length);
- socket.SendAsync (e);
- break;
- case SocketAsyncOperation.Send:
- byte [] buffer = new byte [256];
- e.SetBuffer (buffer, 0, buffer.Length);
- socket.ReceiveAsync (e);
- break;
- case SocketAsyncOperation.Receive:
- int transfer = e.BytesTransferred;
- if (transfer > 0) {
- ms.Write (e.Buffer, 0, transfer);
- // Console.Write (Encoding.UTF8.GetString (e.Buffer, 0, transfer));
- }
-
- if ((transfer == 0) || (transfer < e.Buffer.Length)) {
- ms.Position = 0;
- mre.Set ();
- } else {
- socket.ReceiveAsync (e);
- }
- break;
- }
- };
-
- socket.ConnectAsync (saea);
-
- // behave like there's no policy (no socket access) if we timeout
- if (!mre.WaitOne (Timeout))
- return null;
-
- return ms;
- }
-
- static Stream GetPolicyStream (Uri uri)
- {
- // FIXME
- throw new NotSupportedException ("Fetching socket policy from " + uri.ToString () + " is not yet available in moonlight");
- }
-
- public static ClientAccessPolicy CreateForEndPoint (IPEndPoint endpoint, SocketClientAccessPolicyProtocol protocol)
- {
- Stream s = null;
-
- switch (protocol) {
- case SocketClientAccessPolicyProtocol.Tcp:
- s = GetPolicyStream (endpoint);
- break;
- case SocketClientAccessPolicyProtocol.Http:
- // <quote>It will NOT attempt to download the policy via the custom TCP protocol if the
- // policy check fails.</quote>
- // http://blogs.msdn.com/ncl/archive/2010/04/15/silverlight-4-socket-policy-changes.aspx
- string url = String.Format ("http://{0}:80{1}", endpoint.Address.ToString (),
- CrossDomainPolicyManager.ClientAccessPolicyFile);
- s = GetPolicyStream (new Uri (url));
- break;
- }
-
- if ((s == null) || (s.Length == 0))
- return null;
-
- ClientAccessPolicy policy = null;
- try {
- policy = (ClientAccessPolicy) ClientAccessPolicy.FromStream (s);
- } catch (Exception ex) {
- Console.WriteLine (String.Format ("CrossDomainAccessManager caught an exception while reading {0}: {1}",
- endpoint, ex.Message));
- // and ignore.
- }
-
- return policy;
- }
-
- static public bool CheckEndPoint (EndPoint endpoint, SocketClientAccessPolicyProtocol protocol)
- {
- // if needed transform the DnsEndPoint into a usable IPEndPoint
- IPEndPoint ip = (endpoint as IPEndPoint);
- if (ip == null)
- throw new ArgumentException ("endpoint");
-
- // find the policy (cached or to be downloaded) associated with the endpoint
- string address = ip.Address.ToString ();
- ClientAccessPolicy policy = null;
- if (!socket_policies.TryGetValue (address, out policy)) {
- policy = CreateForEndPoint (ip, protocol);
- socket_policies.Add (address, policy);
- }
-
- // no access granted if no policy is available
- if (policy == null)
- return false;
-
- // does the policy allows access ?
- return policy.IsAllowed (ip);
- }
-#endif
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// FlashCrossDomainPolicy.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace System.Net.Policy {
-
- partial class FlashCrossDomainPolicy : BaseDomainPolicy {
-
- private string site_control;
-
- public FlashCrossDomainPolicy ()
- {
- AllowedAccesses = new List<AllowAccessFrom> ();
- AllowedHttpRequestHeaders = new List<AllowHttpRequestHeadersFrom> ();
- }
-
- public List<AllowAccessFrom> AllowedAccesses { get; private set; }
- public List<AllowHttpRequestHeadersFrom> AllowedHttpRequestHeaders { get; private set; }
-
- public string SiteControl {
- get { return String.IsNullOrEmpty (site_control) ? "all" : site_control; }
- set { site_control = value; }
- }
-
- public override bool IsAllowed (WebRequest request)
- {
- return IsAllowed (request.RequestUri, request.Headers.AllKeys);
- }
-
- public bool IsAllowed (Uri uri, string [] headerKeys)
- {
- switch (SiteControl) {
- case "all":
- case "master-only":
- case "by-ftp-filename":
- break;
- default:
- // others, e.g. 'none', are not supported/accepted
- return false;
- }
-
- if (AllowedAccesses.Count > 0 &&
- !AllowedAccesses.Any (a => a.IsAllowed (uri, headerKeys)))
- return false;
- if (AllowedHttpRequestHeaders.Count > 0 &&
- AllowedHttpRequestHeaders.Any (h => h.IsRejected (uri, headerKeys)))
- return false;
-
- return true;
- }
-
- public class AllowAccessFrom {
-
- public AllowAccessFrom ()
- {
- Secure = true; // true by default
- }
-
- public string Domain { get; set; }
- public bool AllowAnyPort { get; set; }
- public int [] ToPorts { get; set; }
- public bool Secure { get; set; }
-
- public bool IsAllowed (Uri uri, string [] headerKeys)
- {
- // "A Flash policy file must allow access to all domains to be used by the Silverlight runtime."
- // http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx
- if (Domain != "*")
- return false;
- if (!AllowAnyPort && ToPorts != null && Array.IndexOf (ToPorts, uri.Port) < 0)
- return false;
-
- // if Secure is false then it allows applications from HTTP to download data from HTTPS servers
- if (!Secure)
- return true;
- // if Secure is true then data on HTTPS servers can only be accessed by application on HTTPS servers
- if (uri.Scheme == Uri.UriSchemeHttps)
- return (ApplicationUri.Scheme == Uri.UriSchemeHttps);
- // otherwise FILE/HTTP applications can access HTTP uris
- return true;
- }
- }
-
- public class AllowHttpRequestHeadersFrom {
-
- public AllowHttpRequestHeadersFrom ()
- {
- Headers = new Headers ();
- }
-
- public string Domain { get; set; }
- public bool AllowAllHeaders { get; set; }
- public Headers Headers { get; private set; }
- public bool Secure { get; set; }
-
- public bool IsRejected (Uri uri, string [] headerKeys)
- {
- // "A Flash policy file must allow access to all domains to be used by the Silverlight runtime."
- // http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx
- if (Domain != "*")
- return false;
-
- if (Headers.IsAllowed (headerKeys))
- return false;
-
- // if Secure is false then it allows applications from HTTP to download data from HTTPS servers
- if (!Secure)
- return true;
- // if Secure is true then only application on HTTPS servers can access data on HTTPS servers
- if (ApplicationUri.Scheme == Uri.UriSchemeHttps)
- return (uri.Scheme == Uri.UriSchemeHttps);
- // otherwise FILE/HTTP applications can access HTTP uris
- return true;
- }
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// FlashCrossDomainPolicyParser.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Xml;
-
-/*
-
-Specification: http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html
-
-# This grammar is based on the xsd from Adobe, but the schema is wrong.
-# It should have used interleave (all). Some crossdomain.xml are invalidated.
-# (For example, try mono-xmltool --validate-xsd http://www.adobe.com/xml/schemas/PolicyFile.xsd http://twitter.com/crossdomain.xml)
-
-default namespace = ""
-
-grammar {
-
-start = cross-domain-policy
-
-cross-domain-policy = element cross-domain-policy {
- element site-control {
- attribute permitted-cross-domain-policies {
- "all" | "by-contract-type" | "by-ftp-filename" | "master-only" | "none"
- }
- }?,
- element allow-access-from {
- attribute domain { text },
- attribute to-ports { text }?,
- attribute secure { xs:boolean }?
- }*,
- element allow-http-request-headers-from {
- attribute domain { text },
- attribute headers { text },
- attribute secure { xs:boolean }?
- }*,
- element allow-access-from-identity {
- element signatory {
- element certificate {
- attribute fingerprint { text },
- attribute fingerprint-algorithm { text }
- }
- }
- }*
-}
-
-}
-
-*/
-
-namespace System.Net.Policy {
-
- partial class FlashCrossDomainPolicy {
-
- static bool ReadBooleanAttribute (string attribute)
- {
- switch (attribute) {
- case null:
- case "true":
- return true;
- case "false":
- return false;
- default:
- throw new XmlException ();
- }
- }
-
- // only "domain" and "secure" attributes are allowed - anything else is considered invalid
- static AllowAccessFrom CreateAllowAccessFrom (XmlReader reader)
- {
- int n = reader.AttributeCount;
- string domain = reader.GetAttribute ("domain");
- if (domain != null)
- n--;
- string secure = reader.GetAttribute ("secure");
- if (secure != null)
- n--;
- if (n != 0)
- throw new XmlException ("unknown/unsupported attributes");
-
- return new AllowAccessFrom () { Domain = domain, Secure = ReadBooleanAttribute (secure) };
- }
-
- // only "domain", "secure" and "headers" attributes are allowed - anything else is considered invalid
- static AllowHttpRequestHeadersFrom CreateAllowHttpRequestHeadersFrom (XmlReader reader)
- {
- int n = reader.AttributeCount;
- string domain = reader.GetAttribute ("domain");
- if (domain != null)
- n--;
- string secure = reader.GetAttribute ("secure");
- if (secure != null)
- n--;
- string headers = reader.GetAttribute ("headers");
- if (headers != null)
- n--;
- if (n != 0)
- throw new XmlException ("unknown/unsupported attributes");
-
- var h = new AllowHttpRequestHeadersFrom () { Domain = domain, Secure = ReadBooleanAttribute (secure) };
- h.Headers.SetHeaders (headers);
- return h;
- }
-
- // only "permitted-cross-domain-policies" attribute is allowed - anything else is considered invalid
- static string GetSiteControl (XmlReader reader)
- {
- int n = reader.AttributeCount;
- string site = reader.GetAttribute ("permitted-cross-domain-policies");
- if (site != null)
- n--;
- if (n != 0)
- throw new XmlException ("unknown/unsupported attributes");
- return site;
- }
-
- static public ICrossDomainPolicy FromStream (Stream stream)
- {
- FlashCrossDomainPolicy cdp = new FlashCrossDomainPolicy ();
-
- // Silverlight accepts whitespaces before the XML - which is invalid XML
- StreamReader sr = new StreamReader (stream);
- while (Char.IsWhiteSpace ((char) sr.Peek ()))
- sr.Read ();
-
- XmlReaderSettings policy_settings = new XmlReaderSettings ();
- policy_settings.DtdProcessing = DtdProcessing.Ignore;
- using (XmlReader reader = XmlReader.Create (sr, policy_settings)) {
-
- reader.MoveToContent ();
- if (reader.HasAttributes || reader.IsEmptyElement) {
- reader.Skip ();
- return null;
- }
-
- while (!reader.EOF) {
- reader.ReadStartElement ("cross-domain-policy", String.Empty);
- for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
- if (reader.NodeType != XmlNodeType.Element) {
- reader.Skip ();
- continue;
- }
-
- switch (reader.LocalName) {
- case "site-control":
- cdp.SiteControl = GetSiteControl (reader);
- reader.Skip ();
- break;
- case "allow-access-from":
- var a = CreateAllowAccessFrom (reader);
- cdp.AllowedAccesses.Add (a);
- reader.Skip ();
- break;
- case "allow-http-request-headers-from":
- var h = CreateAllowHttpRequestHeadersFrom (reader);
- cdp.AllowedHttpRequestHeaders.Add (h);
- reader.Skip ();
- break;
- default:
- reader.Skip ();
- return null;
- }
- }
- reader.ReadEndElement ();
- reader.MoveToContent ();
- }
- }
-
- // if none supplied set a default for headers
- if (cdp.AllowedHttpRequestHeaders.Count == 0) {
- var h = new AllowHttpRequestHeadersFrom () { Domain = "*", Secure = true };
- h.Headers.SetHeaders (null); // defaults
- cdp.AllowedHttpRequestHeaders.Add (h);
- }
- return cdp;
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Windows.Browser.Net.ICrossDomainPolicy interface
-//
-// Contact:
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Policy {
-
- interface ICrossDomainPolicy {
-
- bool IsAllowed (WebRequest request);
-
- Exception Exception { get; }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Windows.Browser.Net.PolicyDownloadPolicy class
-//
-// Contact:
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.Security;
-
-namespace System.Net.Policy {
-
- sealed class NoAccessPolicy : ICrossDomainPolicy {
-
- static SecurityException security_exception = new SecurityException ();
- static NotSupportedException not_supported_exception = new NotSupportedException ();
-
- Exception ex;
-
- public bool IsAllowed (WebRequest request)
- {
- ex = security_exception;
-
- foreach (string header in request.Headers) {
- if (String.Compare ("Content-Type", header, StringComparison.OrdinalIgnoreCase) != 0)
- ex = not_supported_exception;
- }
- return false;
- }
-
- public Exception Exception {
- get { return ex; }
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Windows.Browser.Net.PolicyDownloadPolicy class
-//
-// Contact:
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Policy {
-
- sealed class PolicyDownloadPolicy : ICrossDomainPolicy {
-
- public bool IsAllowed (WebRequest request)
- {
- return IsLocalPathPolicy (request.RequestUri);
- }
-
- static public bool IsLocalPathPolicy (Uri uri)
- {
- string local = uri.LocalPath;
- if (String.CompareOrdinal (local, CrossDomainPolicyManager.ClientAccessPolicyFile) == 0)
- return true;
- if (String.CompareOrdinal (local, CrossDomainPolicyManager.CrossDomainFile) == 0)
- return true;
-
- return false;
- }
-
- public Exception Exception {
- get { return null; }
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Windows.Browser.Net.SiteOfOriginPolicy class
-//
-// Contact:
-// Moonlight List (moonlight-list@lists.ximian.com)
-//
-// Copyright (C) 2009-2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Policy {
-
- sealed class SiteOfOriginPolicy : ICrossDomainPolicy {
-
- public bool IsAllowed (WebRequest request)
- {
- // a WebRequest to the site of origin (SOO) is always granted
- return true;
- }
-
- // helper to determine if two Uri share the same origin (policy wise)
- static public bool HasSameOrigin (Uri a, Uri b)
- {
- return ((a.Scheme == b.Scheme) && (a.DnsSafeHost == b.DnsSafeHost) &&
- ((a.Port == -1) || (b.Port == -1) || (a.Port == b.Port)));
- }
-
- public Exception Exception {
- get { return null; }
- }
- }
-}
-
-#endif
-
+++ /dev/null
-// AddressFamily.cs (Silverlight specific)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Sockets {
-
- public enum AddressFamily {
- Unknown = -1,
- Unspecified = 0,
- InterNetwork = 2,
- InterNetworkV6 = 23,
- }
-}
-
-#endif
-
+++ /dev/null
-// ProtocolType.cs (Silverlight specific)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Sockets {
-
- public enum ProtocolType {
-
- Unknown = -1,
- Unspecified = 0,
- Tcp = 6
- }
-}
-
-#endif
-
+++ /dev/null
-// System.Net.Sockets.SocketAsyncOperation.cs (Silverlight specific)
-//
-// Authors:
-// Marek Habersack (mhabersack@novell.com)
-//
-// Copyright (c) 2008 Novell, Inc. (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-namespace System.Net.Sockets {
- public enum SocketAsyncOperation {
- None,
- Connect = 2,
- Receive = 4,
- Send = 7,
- }
-}
-#endif
+++ /dev/null
-//
-// SocketClientAccessPolicyProtocol.cs (Silverlight specific)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Net.Sockets {
-
- public enum SocketClientAccessPolicyProtocol {
- Tcp,
- Http
- }
-}
-
+++ /dev/null
-//
-// System.Net.Sockets.SocketException
-//
-// Author:
-// Dick Porter <dick@ximian.com>
-//
-// (C) 2002 Ximian, Inc.
-// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.CompilerServices;
-
-namespace System.Net.Sockets {
-
- public class SocketException : Exception {
-
- int error_code;
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private static extern int WSAGetLastError_internal ();
-
- public SocketException ()
- {
- error_code = WSAGetLastError_internal ();
- }
-
- public SocketException (int errorCode)
- {
- error_code = errorCode;
- }
-
- internal SocketException (int error, string message)
- : base (message)
- {
- error_code = error;
- }
-
- public int ErrorCode {
- get { return error_code; }
- }
-
- public SocketError SocketErrorCode {
- get { return (SocketError) error_code; }
- }
- }
-}
+++ /dev/null
-// SocketType.cs (Silverlight specific)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Sockets {
-
- public enum SocketType {
- Unknown = -1,
- Stream = 1,
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// UdpAnySourceMulticastClient (Moonlight 4.0)
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Sockets {
-
- [MonoTODO ("stub (with some validations) to allow SL4 tests compilation")]
- public class UdpAnySourceMulticastClient : IDisposable {
-
- const string ObjectDisposed = "UdpAnySourceMulticastClient instance was disposed.";
- bool disposed;
-
- public UdpAnySourceMulticastClient (IPAddress groupAddress, int localPort)
- {
- if (groupAddress == null)
- throw new ArgumentNullException ("groupAddress");
- if ((localPort < 0) || (localPort > 65535))
- throw new ArgumentOutOfRangeException ("localPort");
- if (localPort < 1024)
- throw new SocketException ();
-
- throw new NotImplementedException ();
- }
-
- public bool MulticastLoopback { get; set; }
- public int ReceiveBufferSize { get; set; }
- public int SendBufferSize { get; set; }
-
- public IAsyncResult BeginJoinGroup (AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- // check policy
- //throw new SocketException ((int) SocketError.AccessDenied);
- throw new NotImplementedException ();
- // callback called if join operation is completed
- }
-
- public void EndJoinGroup (IAsyncResult result)
- {
- if (result == null)
- throw new ArgumentNullException ("result");
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public IAsyncResult BeginReceiveFromGroup (byte [] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (buffer == null)
- throw new ArgumentNullException ("buffer");
- if ((offset < 0) || (offset > buffer.Length))
- throw new ArgumentOutOfRangeException ("offset");
- if ((count < 0) || (count > buffer.Length - offset))
- throw new ArgumentOutOfRangeException ("count");
-
- throw new NotImplementedException ();
- }
-
- public int EndReceiveFromGroup (IAsyncResult result, out IPEndPoint source)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public IAsyncResult BeginSendTo (byte [] buffer, int offset, int count, IPEndPoint remoteEndPoint, AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (buffer == null)
- throw new ArgumentNullException ("buffer");
- if ((offset < 0) || (offset > buffer.Length))
- throw new ArgumentOutOfRangeException ("offset");
- if ((count < 0) || (count > buffer.Length - offset))
- throw new ArgumentOutOfRangeException ("count");
-
- throw new NotImplementedException ();
- }
-
- public void EndSendTo (IAsyncResult result)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (result == null)
- throw new ArgumentNullException ("result");
-
- throw new NotImplementedException ();
- }
-
- public IAsyncResult BeginSendToGroup (byte [] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (buffer == null)
- throw new ArgumentNullException ("buffer");
- if ((offset < 0) || (offset > buffer.Length))
- throw new ArgumentOutOfRangeException ("offset");
- if ((count < 0) || (count > buffer.Length - offset))
- throw new ArgumentOutOfRangeException ("count");
-
- throw new NotImplementedException ();
- }
-
- public void EndSendToGroup (IAsyncResult result)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (result == null)
- throw new ArgumentNullException ("result");
-
- throw new NotImplementedException ();
- }
-
- public void BlockSource (IPAddress sourceAddress)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public void UnblockSource (IPAddress sourceAddress)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public void Dispose ()
- {
- disposed = true;
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// UdpSingleSourceMulticastClient (Moonlight 4.0)
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net.Sockets {
-
- [MonoTODO ("stub (with some validations) to allow SL4 tests compilation")]
- public class UdpSingleSourceMulticastClient : IDisposable {
-
- const string ObjectDisposed = "UdpSingleSourceMulticastClient instance was disposed.";
- bool disposed;
-
- public UdpSingleSourceMulticastClient (IPAddress sourceAddress, IPAddress groupAddress, int localPort)
- {
- if (sourceAddress == null)
- throw new ArgumentNullException ("sourceAddress");
- if (groupAddress == null)
- throw new ArgumentNullException ("groupAddress");
- if ((localPort < 0) || (localPort > 65535))
- throw new ArgumentOutOfRangeException ("localPort");
- if (localPort < 1024)
- throw new SocketException ();
-
- throw new NotImplementedException ();
- }
-
- public int ReceiveBufferSize { get; set; }
- public int SendBufferSize { get; set; }
-
- public IAsyncResult BeginJoinGroup (AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public void EndJoinGroup (IAsyncResult result)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
-
- throw new NotImplementedException ();
- }
-
- public IAsyncResult BeginReceiveFromSource (byte [] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (buffer == null)
- throw new ArgumentNullException ("buffer");
- if ((offset < 0) || (offset > buffer.Length))
- throw new ArgumentOutOfRangeException ("offset");
- if ((count < 0) || (count > buffer.Length - offset))
- throw new ArgumentOutOfRangeException ("count");
-
- throw new NotImplementedException ();
- }
-
- public int EndReceiveFromSource (IAsyncResult result, out int sourcePort)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (result == null)
- throw new ArgumentNullException ("result");
-
- throw new NotImplementedException ();
- }
-
- public IAsyncResult BeginSendToSource (byte [] buffer, int offset, int count, int remotePort, AsyncCallback callback, object state)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (buffer == null)
- throw new ArgumentNullException ("buffer");
- if ((offset < 0) || (offset > buffer.Length))
- throw new ArgumentOutOfRangeException ("offset");
- if ((count < 0) || (count > buffer.Length - offset))
- throw new ArgumentOutOfRangeException ("count");
-
- throw new NotImplementedException ();
- }
-
- public void EndSendToSource (IAsyncResult result)
- {
- if (disposed)
- throw new ObjectDisposedException (ObjectDisposed);
- if (result == null)
- throw new ArgumentNullException ("result");
-
- throw new NotImplementedException ();
- }
-
- public void Dispose ()
- {
- disposed = true;
- }
- }
-}
-
-#endif
-
Assembly/TypeForwarders.cs
../../build/common/Consts.cs
../../build/common/MonoTODOAttribute.cs
-System.Net/IPEndPointCollection.cs
+../referencesource/System.Net/net/IPEndPointCollection.cs
+++ /dev/null
-// System.Net.Dns.cs
-//
-// Author: Mads Pultz (mpultz@diku.dk)
-// Author: Lawrence Pit (loz@cable.a2000.nl)
-//
-// (C) Mads Pultz, 2001
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Net.Sockets;
-using System.Runtime.CompilerServices;
-
-namespace System.Net {
-
- internal static class Dns {
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern static bool GetHostByName_internal(string host, out string h_name, out string[] h_aliases, out string[] h_addr_list);
-
- internal static IPAddress [] GetHostAddresses (string hostNameOrAddress)
- {
- if (hostNameOrAddress == null)
- throw new ArgumentNullException ("hostNameOrAddress");
-
- if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0")
- throw new ArgumentException ("Addresses 0.0.0.0 (IPv4) " +
- "and ::0 (IPv6) are unspecified addresses. You " +
- "cannot use them as target address.",
- "hostNameOrAddress");
-
- IPAddress addr;
- if (hostNameOrAddress.Length > 0 && IPAddress.TryParse (hostNameOrAddress, out addr))
- return new IPAddress[1] { addr };
-
- string h_name;
- string[] h_aliases, h_addrlist;
-
- bool ret = GetHostByName_internal (hostNameOrAddress, out h_name, out h_aliases, out h_addrlist);
- if (ret == false)
- throw new SocketException(11001);
-
- IPHostEntry entry = hostent_to_IPHostEntry (h_name, h_aliases, h_addrlist);
- return entry.AddressList;
- }
-
- private static IPHostEntry hostent_to_IPHostEntry(string h_name, string[] h_aliases, string[] h_addrlist)
- {
- IPHostEntry he = new IPHostEntry();
- ArrayList addrlist = new ArrayList();
-
- he.HostName = h_name;
- he.Aliases = h_aliases;
- for(int i=0; i<h_addrlist.Length; i++) {
- try {
- IPAddress newAddress = IPAddress.Parse(h_addrlist[i]);
-
- if( (Socket.SupportsIPv6 && newAddress.AddressFamily == AddressFamily.InterNetworkV6) ||
- (Socket.SupportsIPv4 && newAddress.AddressFamily == AddressFamily.InterNetwork) )
- addrlist.Add(newAddress);
- } catch (ArgumentNullException) {
- /* Ignore this, as the
- * internal call might have
- * left some blank entries at
- * the end of the array
- */
- }
- }
-
- if(addrlist.Count == 0)
- throw new SocketException(11001);
-
- he.AddressList = addrlist.ToArray(typeof(IPAddress)) as IPAddress[];
- return he;
- }
- }
-}
-
+++ /dev/null
-//
-// System.Net.HttpWebRequest (for 2.1 profile)
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Jb Evain <jbevain@novell.com>
-//
-// Copyright (C) 2007, 2009-2011 Novell, Inc (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.IO;
-
-namespace System.Net {
-
- // note: the NotImplementedException are needed to match MS implementation
-
- // note: MS documents a lot of thing for this type but, in truth, all happens
- // in a type that derive from HttpWebRequest. In Moonlight case this is either
- // * BrowserHttpWebRequest (browser stack) located in System.Windows.Browser.dll; or
- // * System.Net.Browser.ClientHttpWebRequest (client stack) located in System.Windows.dll
-
- public abstract class HttpWebRequest : WebRequest {
-
- private WebHeaderCollection headers;
-
- protected HttpWebRequest ()
- {
- }
-
- public string Accept {
- get { return Headers [HttpRequestHeader.Accept]; }
- // this header cannot be set directly inside the collection (hence the helper)
- set { Headers.SetHeader ("accept", value); }
- }
-
- public virtual bool AllowReadStreamBuffering {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- // new in SL4 RC
- public virtual bool AllowWriteStreamBuffering {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- public override string ContentType {
- get { return Headers [HttpRequestHeader.ContentType]; }
- // this header cannot be set directly inside the collection (hence the helper)
- set { Headers.SetHeader ("content-type", value); }
- }
-
- public virtual bool HaveResponse {
- get { throw NotImplemented (); }
- }
-
- public override WebHeaderCollection Headers {
- get {
- if (headers == null)
- headers = new WebHeaderCollection (true);
- return headers;
- }
- set {
- // note: this is not a field assignment but a copy (see unit tests)
- // make sure everything we're supplied is valid...
- foreach (string header in value) {
- // anything bad will throw
- WebHeaderCollection.ValidateHeader (header);
- }
- // ... before making those values our own
- Headers.Clear ();
- foreach (string header in value) {
- headers [header] = value [header];
- }
- }
- }
-
- public virtual CookieContainer CookieContainer {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- public override string Method {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- public override Uri RequestUri {
- get { throw NotImplemented (); }
- }
-
- // new in SL4
- public virtual bool SupportsCookieContainer {
- get { return false; }
- }
-
- // new in SL4 (service release) : WP7 binary compatibility - not for use in SL4 applications (MSDN docs)
- public virtual bool AllowAutoRedirect {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- // new in SL4 (service release) : WP7 binary compatibility - not for use in SL4 applications (MSDN docs)
- public string UserAgent {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- public override void Abort ()
- {
- throw NotImplemented ();
- }
-
- public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state)
- {
- throw NotImplemented ();
- }
-
- public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
- {
- throw NotImplemented ();
- }
-
- public override Stream EndGetRequestStream (IAsyncResult asyncResult)
- {
- throw NotImplemented ();
- }
-
- public override WebResponse EndGetResponse (IAsyncResult asyncResult)
- {
- throw NotImplemented ();
- }
-
- static Exception NotImplemented ()
- {
- // a bit less IL and hide the "normal" NotImplementedException from corcompare-like tools
- return new NotImplementedException ();
- }
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Net.HttpWebResponse (for 2.1 profile)
-//
-// Authors:
-// Atsushi Enomoto <atsushi@ximian.com>
-// Jb Evain <jbevain@novell.com>
-//
-// Copyright (C) 2007, 2009 Novell, Inc (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net {
-
- public abstract class HttpWebResponse : WebResponse {
-
- public virtual string Method {
- get { throw NotImplemented (); }
- }
-
- public virtual HttpStatusCode StatusCode {
- get { throw NotImplemented (); }
- }
-
- public virtual string StatusDescription {
- get { throw NotImplemented (); }
- }
-
- public virtual CookieCollection Cookies {
- get { throw NotImplemented (); }
- }
-
- static Exception NotImplemented ()
- {
- // hide the "normal" NotImplementedException from corcompare-like tools
- return new NotImplementedException ();
- }
- }
-}
-
-#endif
+++ /dev/null
-// System.Net.IPEndPointCollection
-//
-// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using System;
-using System.Collections.ObjectModel;
-
-namespace System.Net {
- public class IPEndPointCollection : Collection<IPEndPoint> {
- public IPEndPointCollection ()
- {
- }
-
- protected override void InsertItem (int index, IPEndPoint item)
- {
- if (item == null)
- throw new ArgumentNullException ("item");
-
- Items.Insert (index, item);
- }
-
- protected override void SetItem (int index, IPEndPoint item)
- {
- if (item == null)
- throw new ArgumentNullException ("item");
-
- Items [index] = item;
- }
- }
-}
-
+++ /dev/null
-/*
- * InternalWebRequestStreamWrapper.cs.
- *
- * Contact:
- * Moonlight List (moonlight-list@lists.ximian.com)
- *
- * Copyright 2008,2010 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-using System.IO;
-
-namespace System.Net {
-
- internal sealed class InternalWebRequestStreamWrapper : Stream {
-
- MemoryStream stream;
- byte[] data;
-
- internal InternalWebRequestStreamWrapper (MemoryStream s)
- {
- stream = s;
- }
-
- public override bool CanRead {
- get {
- return stream.CanRead;
- }
- }
-
- public override bool CanSeek {
- get {
- return stream.CanSeek;
- }
- }
-
- public override bool CanWrite {
- get {
- return stream.CanWrite;
- }
- }
-
- public override long Length {
- get {
- return stream.Length;
- }
- }
-
- public override long Position {
- get {
- return stream.Position;
- }
- set {
- stream.Position = value;
- }
- }
-
- public override void Flush ()
- {
- stream.Flush ();
- }
-
- public override void Close ()
- {
- try {
- // When we POST data then the actual bytes are needed after the stream is closed (e.g. DRT287)
- // However a MemoryStream will clear itself and throw ObjectDisposedException in such case
- data = stream.ToArray ();
- stream.Close ();
- }
- finally {
- // if used from WebClient then notify that the stream was closed
- if (WebClient != null) {
- WebClient.WriteStreamClosedCallback (WebClientData, data.Length);
- WebClient = null; // notify only once
- }
- }
- }
-
- public override void SetLength (long value)
- {
- stream.SetLength (value);
- }
-
- public override int Read (byte [] buffer, int offset, int count)
- {
- return stream.Read (buffer, offset, count);
- }
-
- public override void Write (byte [] buffer, int offset, int count)
- {
- stream.Write (buffer, offset, count);
- }
-
- public override void WriteByte (byte value)
- {
- stream.WriteByte (value);
- }
-
- public override long Seek (long offset, SeekOrigin origin)
- {
- return stream.Seek (offset, origin);
- }
-
- internal byte[] GetData ()
- {
- // hold a copy of the data if the stream was closed
- return data;
- }
-
- internal MemoryStream InnerStream {
- get { return stream; }
- }
-
- internal WebClient WebClient {
- get; set;
- }
-
- internal object WebClientData {
- get; set;
- }
- }
-}
-
+++ /dev/null
-//
-// System.Net.WebClient
-//
-// Authors:
-// Lawrence Pit (loz@cable.a2000.nl)
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-// Atsushi Enomoto (atsushi@ximian.com)
-// Miguel de Icaza (miguel@ximian.com)
-// Stephane Delcroix (sdelcroix@novell.com)
-//
-// Copyright 2003 Ximian, Inc. (http://www.ximian.com)
-// Copyright 2006, 2008, 2009-2010 Novell, Inc. (http://www.novell.com)
-//
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.IO;
-using System.Security;
-using System.Text;
-using System.Threading;
-
-namespace System.Net {
-
- // note: this type is effectively sealed to transparent code since it's default .ctor is marked with [SecuritySafeCritical]
- public class WebClient {
-
- WebHeaderCollection headers;
- WebHeaderCollection responseHeaders;
- bool response_supports_headers = true; // will be set to false, if needed, when we get a response
- string baseAddress;
- Uri base_address_uri;
- bool is_busy;
- Encoding encoding = Encoding.UTF8;
- bool allow_read_buffering = true;
- bool allow_write_buffering = true;
- WebRequest request;
- object locker;
- CallbackData callback_data;
- long upload_length;
-
- public WebClient ()
- {
- // kind of calling NativeMethods.plugin_instance_get_source_location (PluginHost.Handle)
- // but without adding dependency on System.Windows.dll. GetData is [SecurityCritical]
- // this makes the default .ctor [SecuritySafeCritical] which would be a problem (inheritance)
- // but it happens that MS SL2 also has this default .ctor as SSC :-)
- BaseAddress = (AppDomain.CurrentDomain.GetData ("xap_uri") as string);
- locker = new object ();
- UseDefaultCredentials = true;
- }
-
- // Properties
-
- public string BaseAddress {
- get { return baseAddress; }
- set {
- if (String.IsNullOrEmpty (value)) {
- baseAddress = String.Empty;
- base_address_uri = null;
- } else {
- if (!Uri.TryCreate (value, UriKind.Absolute, out base_address_uri))
- throw new ArgumentException ("Invalid URI");
-
- baseAddress = Uri.UnescapeDataString (base_address_uri.AbsoluteUri);
- }
- }
- }
-
- [MonoTODO ("provide credentials to the client stack")]
- public ICredentials Credentials { get; set; }
-
- // this is an unvalidated collection, HttpWebRequest is responsable to validate it
- public WebHeaderCollection Headers {
- get {
- if (headers == null)
- headers = new WebHeaderCollection ();
-
- return headers;
- }
- set { headers = value; }
- }
-
- public WebHeaderCollection ResponseHeaders {
- get {
- if (!response_supports_headers)
- throw new NotImplementedException ();
- return responseHeaders;
- }
- }
-
- public Encoding Encoding {
- get { return encoding; }
- set {
- if (value == null)
- throw new ArgumentNullException ("value");
- encoding = value;
- }
- }
-
- public bool IsBusy {
- get { return is_busy; }
- }
-
- [MonoTODO ("value is unused, current implementation always works like it's true (default)")]
- public bool AllowReadStreamBuffering {
- get { return allow_read_buffering; }
- set { allow_read_buffering = value; }
- }
-
- // new in SL4 RC
- [MonoTODO ("value is unused, current implementation always works like it's true (default)")]
- public bool AllowWriteStreamBuffering {
- get { return allow_write_buffering; }
- set { allow_write_buffering = value; }
- }
-
- public bool UseDefaultCredentials {
- get; set;
- }
-
- // Methods
-
- void CheckBusy ()
- {
- if (IsBusy)
- throw new NotSupportedException ("WebClient does not support concurrent I/O operations.");
- }
-
- void SetBusy ()
- {
- lock (locker) {
- CheckBusy ();
- is_busy = true;
- }
- }
-
- private string DetermineMethod (Uri address, string method)
- {
- if (method != null)
- return method;
-
- if (address.Scheme == Uri.UriSchemeFtp)
- return "RETR";
- return "POST";
- }
-
- public event DownloadProgressChangedEventHandler DownloadProgressChanged;
- public event DownloadStringCompletedEventHandler DownloadStringCompleted;
- public event OpenReadCompletedEventHandler OpenReadCompleted;
- public event OpenWriteCompletedEventHandler OpenWriteCompleted;
- public event UploadProgressChangedEventHandler UploadProgressChanged;
- public event UploadStringCompletedEventHandler UploadStringCompleted;
- public event WriteStreamClosedEventHandler WriteStreamClosed;
-
- WebRequest SetupRequest (Uri uri, string method, CallbackData callbackData)
- {
- callback_data = callbackData;
- WebRequest request = GetWebRequest (uri);
- // do not send a relative URI to Determine method
- request.Method = DetermineMethod (request.RequestUri, method);
- // copy headers to the request - some needs special treatments
- foreach (string header in Headers) {
- switch (header.ToLowerInvariant ()) {
- case "content-length":
- long cl = 0;
- if (Int64.TryParse (Headers [header], out cl) && (cl >= 0))
- request.ContentLength = cl;
- break;
- case "accept":
- case "content-type":
- // this skip the normal/user validation on headers
- request.Headers.SetHeader (header, Headers [header]);
- break;
- default:
- request.Headers [header] = Headers [header];
- break;
- }
- }
- // original headers are removed after calls
- Headers.Clear ();
- return request;
- }
-
- Stream ProcessResponse (WebResponse response)
- {
- response_supports_headers = response.SupportsHeaders;
- if (response_supports_headers)
- responseHeaders = response.Headers;
-
- HttpWebResponse hwr = (response as HttpWebResponse);
- if (hwr == null)
- throw new NotSupportedException ();
-
- HttpStatusCode status_code = HttpStatusCode.NotFound;
- Stream s = null;
- try {
- status_code = hwr.StatusCode;
- if (status_code == HttpStatusCode.OK)
- s = response.GetResponseStream ();
- }
- catch (Exception e) {
- throw new WebException ("NotFound", status_code == HttpStatusCode.OK ? e : null,
- WebExceptionStatus.UnknownError, response);
- }
- return s;
- }
-
- public void CancelAsync ()
- {
- if (request != null)
- request.Abort ();
- upload_length = 0;
- }
-
- void CompleteAsync ()
- {
- is_busy = false;
- upload_length = 0;
- }
-
- internal class CallbackData {
- public object user_token;
- public SynchronizationContext sync_context;
- public byte [] data;
- public CallbackData (object user_token, byte [] data)
- {
- this.user_token = user_token;
- this.data = data;
- this.sync_context = SynchronizationContext.Current ?? new SynchronizationContext ();
- }
- public CallbackData (object user_token) : this (user_token, null)
- {
- }
- }
-
- // DownloadStringAsync
-
- public void DownloadStringAsync (Uri address)
- {
- DownloadStringAsync (address, null);
- }
-
- public void DownloadStringAsync (Uri address, object userToken)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- lock (locker) {
- SetBusy ();
-
- try {
- request = SetupRequest (address, "GET", new CallbackData (userToken));
- request.BeginGetResponse (new AsyncCallback (DownloadStringAsyncCallback), null);
- }
- catch (Exception e) {
- WebException wex = new WebException ("Could not start operation.", e);
- OnDownloadStringCompleted (
- new DownloadStringCompletedEventArgs (null, wex, false, userToken));
- }
- }
- }
-
- private void DownloadStringAsyncCallback (IAsyncResult result)
- {
- string data = null;
- Exception ex = null;
- bool cancel = false;
- try {
- WebResponse response = request.EndGetResponse (result);
- Stream stream = ProcessResponse (response);
-
- using (StreamReader sr = new StreamReader (stream, encoding, true)) {
- data = sr.ReadToEnd ();
- }
- }
- catch (WebException web) {
- cancel = (web.Status == WebExceptionStatus.RequestCanceled);
- ex = web;
- }
- catch (SecurityException se) {
- // SecurityException inside a SecurityException (not a WebException) for SL compatibility
- ex = new SecurityException (String.Empty, se);
- }
- catch (Exception e) {
- ex = new WebException ("Could not complete operation.", e, WebExceptionStatus.UnknownError, null);
- }
- finally {
- callback_data.sync_context.Post (delegate (object sender) {
- OnDownloadStringCompleted (new DownloadStringCompletedEventArgs (data, ex, cancel, callback_data.user_token));
- }, null);
- }
- }
-
- // OpenReadAsync
-
- public void OpenReadAsync (Uri address)
- {
- OpenReadAsync (address, null);
- }
-
- public void OpenReadAsync (Uri address, object userToken)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- lock (locker) {
- SetBusy ();
-
- try {
- request = SetupRequest (address, "GET", new CallbackData (userToken));
- request.BeginGetResponse (new AsyncCallback (OpenReadAsyncCallback), null);
- }
- catch (Exception e) {
- WebException wex = new WebException ("Could not start operation.", e);
- OnOpenReadCompleted (
- new OpenReadCompletedEventArgs (null, wex, false, userToken));
- }
- }
- }
-
- private void OpenReadAsyncCallback (IAsyncResult result)
- {
- Stream stream = null;
- Exception ex = null;
- bool cancel = false;
- try {
- WebResponse response = request.EndGetResponse (result);
- stream = ProcessResponse (response);
- }
- catch (WebException web) {
- cancel = (web.Status == WebExceptionStatus.RequestCanceled);
- ex = web;
- }
- catch (SecurityException se) {
- // SecurityException inside a SecurityException (not a WebException) for SL compatibility
- ex = new SecurityException (String.Empty, se);
- }
- catch (Exception e) {
- ex = new WebException ("Could not complete operation.", e, WebExceptionStatus.UnknownError, null);
- }
- finally {
- callback_data.sync_context.Post (delegate (object sender) {
- OnOpenReadCompleted (new OpenReadCompletedEventArgs (stream, ex, cancel, callback_data.user_token));
- }, null);
- }
- }
-
- // OpenWriteAsync
-
- public void OpenWriteAsync (Uri address)
- {
- OpenWriteAsync (address, null);
- }
-
- public void OpenWriteAsync (Uri address, string method)
- {
- OpenWriteAsync (address, method, null);
- }
-
- public void OpenWriteAsync (Uri address, string method, object userToken)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- lock (locker) {
- SetBusy ();
-
- try {
- request = SetupRequest (address, method, new CallbackData (userToken));
- request.BeginGetRequestStream (new AsyncCallback (OpenWriteAsyncCallback), null);
- }
- catch (Exception e) {
- WebException wex = new WebException ("Could not start operation.", e);
- OnOpenWriteCompleted (
- new OpenWriteCompletedEventArgs (null, wex, false, userToken));
- }
- }
- }
-
- private void OpenWriteAsyncCallback (IAsyncResult result)
- {
- Stream stream = null;
- Exception ex = null;
- bool cancel = false;
- InternalWebRequestStreamWrapper internal_stream;
-
- try {
- stream = request.EndGetRequestStream (result);
- internal_stream = (InternalWebRequestStreamWrapper) stream;
- internal_stream.WebClient = this;
- internal_stream.WebClientData = callback_data;
- }
- catch (WebException web) {
- cancel = (web.Status == WebExceptionStatus.RequestCanceled);
- ex = web;
- }
- catch (Exception e) {
- ex = new WebException ("Could not complete operation.", e, WebExceptionStatus.UnknownError, null);
- }
- finally {
- callback_data.sync_context.Post (delegate (object sender) {
- OnOpenWriteCompleted (new OpenWriteCompletedEventArgs (stream, ex, cancel, callback_data.user_token));
- }, null);
- }
- }
-
- internal void WriteStreamClosedCallback (object WebClientData, long length)
- {
- try {
- request.BeginGetResponse (OpenWriteAsyncResponseCallback, WebClientData);
- }
- catch (Exception e) {
- callback_data.sync_context.Post (delegate (object sender) {
- OnWriteStreamClosed (new WriteStreamClosedEventArgs (e));
- }, null);
- }
- finally {
- // kind of dummy, 0% progress, that is always emitted
- upload_length = length;
- callback_data.sync_context.Post (delegate (object sender) {
- OnUploadProgressChanged (
- new UploadProgressChangedEventArgs (0, -1, length, -1, 0, callback_data.user_token));
- }, null);
- }
- }
-
- private void OpenWriteAsyncResponseCallback (IAsyncResult result)
- {
- Exception ex = null;
- try {
- WebResponse response = request.EndGetResponse (result);
- ProcessResponse (response);
- }
- catch (SecurityException se) {
- // SecurityException inside a SecurityException (not a WebException) for SL compatibility
- ex = new SecurityException (String.Empty, se);
- }
- catch (Exception e) {
- ex = new WebException ("Could not complete operation.", e, WebExceptionStatus.UnknownError, null);
- }
- finally {
- callback_data.sync_context.Post (delegate (object sender) {
- OnWriteStreamClosed (new WriteStreamClosedEventArgs (ex));
- }, null);
- }
- }
-
- // UploadStringAsync
-
- public void UploadStringAsync (Uri address, string data)
- {
- UploadStringAsync (address, null, data);
- }
-
- public void UploadStringAsync (Uri address, string method, string data)
- {
- UploadStringAsync (address, method, data, null);
- }
-
- public void UploadStringAsync (Uri address, string method, string data, object userToken)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
- if (data == null)
- throw new ArgumentNullException ("data");
-
- lock (locker) {
- SetBusy ();
-
- try {
- CallbackData cbd = new CallbackData (userToken, encoding.GetBytes (data));
- request = SetupRequest (address, method, cbd);
- request.BeginGetRequestStream (new AsyncCallback (UploadStringRequestAsyncCallback), cbd);
- }
- catch (Exception e) {
- WebException wex = new WebException ("Could not start operation.", e);
- OnUploadStringCompleted (
- new UploadStringCompletedEventArgs (null, wex, false, userToken));
- }
- }
- }
-
- private void UploadStringRequestAsyncCallback (IAsyncResult result)
- {
- try {
- Stream stream = request.EndGetRequestStream (result);
- stream.Write (callback_data.data, 0, callback_data.data.Length);
- request.BeginGetResponse (new AsyncCallback (UploadStringResponseAsyncCallback), null);
- }
- catch {
- request.Abort ();
- throw;
- }
- finally {
- // kind of dummy, 0% progress, that is always emitted
- upload_length = callback_data.data.Length;
- callback_data.sync_context.Post (delegate (object sender) {
- OnUploadProgressChanged (
- new UploadProgressChangedEventArgs (0, -1, upload_length, -1, 0, callback_data.user_token));
- }, "null");
- }
- }
-
- private void UploadStringResponseAsyncCallback (IAsyncResult result)
- {
- string data = null;
- Exception ex = null;
- bool cancel = false;
- try {
- WebResponse response = request.EndGetResponse (result);
- Stream stream = ProcessResponse (response);
-
- using (StreamReader sr = new StreamReader (stream, encoding, true)) {
- data = sr.ReadToEnd ();
- }
- }
- catch (WebException web) {
- cancel = (web.Status == WebExceptionStatus.RequestCanceled);
- ex = web;
- }
- catch (SecurityException se) {
- // SecurityException inside a SecurityException (not a WebException) for SL compatibility
- ex = new SecurityException (String.Empty, se);
- }
- catch (Exception e) {
- ex = new WebException ("Could not complete operation.", e, WebExceptionStatus.UnknownError, null);
- }
- finally {
- callback_data.sync_context.Post (delegate (object sender) {
- OnUploadStringCompleted (new UploadStringCompletedEventArgs (data, ex, cancel, callback_data.user_token));
- }, null);
- }
- }
-
- protected virtual void OnDownloadProgressChanged (DownloadProgressChangedEventArgs e)
- {
- DownloadProgressChangedEventHandler handler = DownloadProgressChanged;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnOpenReadCompleted (OpenReadCompletedEventArgs e)
- {
- CompleteAsync ();
- OpenReadCompletedEventHandler handler = OpenReadCompleted;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnDownloadStringCompleted (DownloadStringCompletedEventArgs e)
- {
- CompleteAsync ();
- DownloadStringCompletedEventHandler handler = DownloadStringCompleted;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnOpenWriteCompleted (OpenWriteCompletedEventArgs e)
- {
- CompleteAsync ();
- OpenWriteCompletedEventHandler handler = OpenWriteCompleted;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnUploadProgressChanged (UploadProgressChangedEventArgs e)
- {
- UploadProgressChangedEventHandler handler = UploadProgressChanged;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnUploadStringCompleted (UploadStringCompletedEventArgs e)
- {
- CompleteAsync ();
- UploadStringCompletedEventHandler handler = UploadStringCompleted;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual void OnWriteStreamClosed (WriteStreamClosedEventArgs e)
- {
- CompleteAsync ();
- WriteStreamClosedEventHandler handler = WriteStreamClosed;
- if (handler != null)
- handler (this, e);
- }
-
- protected virtual WebRequest GetWebRequest (Uri address)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- // if the URI is relative then we use our base address URI to make an absolute one
- Uri uri = address.IsAbsoluteUri || base_address_uri == null ? address : new Uri (base_address_uri, address);
-
- HttpWebRequest request = (HttpWebRequest) WebRequest.Create (uri);
- request.AllowReadStreamBuffering = AllowReadStreamBuffering;
- request.AllowWriteStreamBuffering = AllowWriteStreamBuffering;
- request.UseDefaultCredentials = UseDefaultCredentials;
-
- request.progress = delegate (long read, long length) {
- callback_data.sync_context.Post (delegate (object sender) {
- if (upload_length > 0) {
- // always emitted as 50% with an unknown (-1) TotalBytesToSend
- OnUploadProgressChanged (new UploadProgressChangedEventArgs (read, length,
- upload_length, -1, 50, callback_data.user_token));
- } else {
- OnDownloadProgressChanged (new DownloadProgressChangedEventArgs (read, length,
- callback_data.user_token));
- }
- }, null);
- };
- return request;
- }
-
- protected virtual WebResponse GetWebResponse (WebRequest request, IAsyncResult result)
- {
- return request.EndGetResponse (result);
- }
- }
-}
-
+++ /dev/null
-// System.Net.WebExceptionStatus.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// originally autogenerated by Sergey Chaban (serge@wildwestsoftware.com)
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net {
- public enum WebExceptionStatus {
- Success = 0,
- ConnectFailure = 2,
- SendFailure = 4,
- RequestCanceled = 6,
- Pending = 13,
- UnknownError = 16,
- MessageLengthLimitExceeded = 17,
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Net.WebHeaderCollection (for 2.1 profile)
-//
-// Authors:
-// Jb Evain <jbevain@novell.com>
-// Sebastien Pouliot <sebastien@ximian.com>
-// Lawrence Pit (loz@cable.a2000.nl)
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-// Miguel de Icaza (miguel@novell.com)
-//
-// Copyright 2003 Ximian, Inc. (http://www.ximian.com)
-// (c) 2007, 2009-2010 Novell, Inc. (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace System.Net {
-
- public sealed class WebHeaderCollection : IEnumerable {
-
- Dictionary<string, string> headers;
- bool validate;
-
- public WebHeaderCollection ()
- : this (false)
- {
- }
-
- internal WebHeaderCollection (bool restrict)
- {
- validate = restrict;
- headers = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase);
- }
-
- public int Count {
- get { return headers.Count; }
- }
-
- public string [] AllKeys {
- get {
- var keys = new string [headers.Count];
- headers.Keys.CopyTo (keys, 0);
- return keys;
- }
- }
-
- public string this [string header] {
- get {
- if (header == null)
- throw new ArgumentNullException ("header");
-
- string value = null;
- headers.TryGetValue (header, out value);
- return value;
- }
- set {
- if (header == null)
- throw new ArgumentNullException ("header");
- if (!IsHeaderName (header))
- throw new ArgumentException ("header");
-
- if (validate)
- ValidateHeader (header);
-
- // null value are ignored (see moon-unit)
- if (value == null)
- return;
- if (!IsHeaderValue (value))
- throw new ArgumentException ("value");
-
- headers [header] = value;
- }
- }
-
- public string this [HttpRequestHeader header] {
- get { return this [HttpRequestHeaderToString (header)]; }
- set {
- string h = HttpRequestHeaderToString (header);
- if (validate)
- ValidateHeader (h);
- headers [h] = value;
- }
- }
-
- // some headers cannot be set using the "this" property but by using
- // the right property of the Web[Request|Response]. However the value
- // does end up in the collection (and can be read safely from there)
- internal void SetHeader (string header, string value)
- {
- if (String.IsNullOrEmpty (value))
- headers.Remove (header);
- else
- headers [header] = value;
- }
-
- internal void Clear ()
- {
- headers.Clear ();
- }
-
- internal bool ContainsKey (string key)
- {
- return headers.ContainsKey (key);
- }
-
- IEnumerator IEnumerable.GetEnumerator ()
- {
- return headers.Keys.GetEnumerator ();
- }
-
- static string HttpResponseHeaderToString (HttpResponseHeader header)
- {
- switch (header) {
- case HttpResponseHeader.CacheControl: return "Cache-Control";
- case HttpResponseHeader.Connection: return "Connection";
- case HttpResponseHeader.Date: return "Date";
- case HttpResponseHeader.KeepAlive: return "Keep-Alive";
- case HttpResponseHeader.Pragma: return "Pragma";
- case HttpResponseHeader.Trailer: return "Trailer";
- case HttpResponseHeader.TransferEncoding: return "Transfer-Encoding";
- case HttpResponseHeader.Upgrade: return "Upgrade";
- case HttpResponseHeader.Via: return "Via";
- case HttpResponseHeader.Warning: return "Warning";
- case HttpResponseHeader.Allow: return "Allow";
- case HttpResponseHeader.ContentLength: return "Content-Length";
- case HttpResponseHeader.ContentType: return "Content-Type";
- case HttpResponseHeader.ContentEncoding: return "Content-Encoding";
- case HttpResponseHeader.ContentLanguage: return "Content-Language";
- case HttpResponseHeader.ContentLocation: return "Content-Location";
- case HttpResponseHeader.ContentMd5: return "Content-MD5";
- case HttpResponseHeader.ContentRange: return "Content-Range";
- case HttpResponseHeader.Expires: return "Expires";
- case HttpResponseHeader.LastModified: return "Last-Modified";
- case HttpResponseHeader.AcceptRanges: return "Accept-Ranges";
- case HttpResponseHeader.Age: return "Age";
- case HttpResponseHeader.ETag: return "ETag";
- case HttpResponseHeader.Location: return "Location";
- case HttpResponseHeader.ProxyAuthenticate: return "Proxy-Authenticate";
- case HttpResponseHeader.RetryAfter: return "Retry-After";
- case HttpResponseHeader.Server: return "Server";
- case HttpResponseHeader.SetCookie: return "Set-Cookie";
- case HttpResponseHeader.Vary: return "Vary";
- case HttpResponseHeader.WwwAuthenticate: return "WWW-Authenticate";
- default:
- throw new IndexOutOfRangeException ();
- }
- }
-
- static string HttpRequestHeaderToString (HttpRequestHeader header)
- {
- switch (header) {
- case HttpRequestHeader.CacheControl: return "Cache-Control";
- case HttpRequestHeader.Connection: return "Connection";
- case HttpRequestHeader.Date: return "Date";
- case HttpRequestHeader.KeepAlive: return "Keep-Alive";
- case HttpRequestHeader.Pragma: return "Pragma";
- case HttpRequestHeader.Trailer: return "Trailer";
- case HttpRequestHeader.TransferEncoding: return "Transfer-Encoding";
- case HttpRequestHeader.Upgrade: return "Upgrade";
- case HttpRequestHeader.Via: return "Via";
- case HttpRequestHeader.Warning: return "Warning";
- case HttpRequestHeader.Allow: return "Allow";
- case HttpRequestHeader.ContentLength: return "Content-Length";
- case HttpRequestHeader.ContentType: return "Content-Type";
- case HttpRequestHeader.ContentEncoding: return "Content-Encoding";
- case HttpRequestHeader.ContentLanguage: return "Content-Language";
- case HttpRequestHeader.ContentLocation: return "Content-Location";
- case HttpRequestHeader.ContentMd5: return "Content-MD5";
- case HttpRequestHeader.ContentRange: return "Content-Range";
- case HttpRequestHeader.Expires: return "Expires";
- case HttpRequestHeader.LastModified: return "Last-Modified";
- case HttpRequestHeader.Accept: return "Accept";
- case HttpRequestHeader.AcceptCharset: return "Accept-Charset";
- case HttpRequestHeader.AcceptEncoding: return "Accept-Encoding";
- case HttpRequestHeader.AcceptLanguage: return "Accept-Language";
- case HttpRequestHeader.Authorization: return "Authorization";
- case HttpRequestHeader.Cookie: return "Cookie";
- case HttpRequestHeader.Expect: return "Expect";
- case HttpRequestHeader.From: return "From";
- case HttpRequestHeader.Host: return "Host";
- case HttpRequestHeader.IfMatch: return "If-Match";
- case HttpRequestHeader.IfModifiedSince: return "If-Modified-Since";
- case HttpRequestHeader.IfNoneMatch: return "If-None-Match";
- case HttpRequestHeader.IfRange: return "If-Range";
- case HttpRequestHeader.IfUnmodifiedSince: return "If-Unmodified-Since";
- case HttpRequestHeader.MaxForwards: return "Max-Forwards";
- case HttpRequestHeader.ProxyAuthorization: return "Proxy-Authorization";
- case HttpRequestHeader.Referer: return "Referer";
- case HttpRequestHeader.Range: return "Range";
- case HttpRequestHeader.Te: return "TE";
- case HttpRequestHeader.Translate: return "Translate";
- case HttpRequestHeader.UserAgent: return "User-Agent";
- default:
- throw new IndexOutOfRangeException ();
- }
- }
-
- internal static void ValidateHeader (string header)
- {
- switch (header.ToLowerInvariant ()) {
- case "connection":
- case "date":
- case "keep-alive":
- case "trailer":
- case "transfer-encoding":
- case "upgrade":
- case "via":
- case "warning":
- case "allow":
- case "content-length": // accepted by WebClient, copied to WebRequest.ContentLength (not headers)
- case "content-type": // accepted by WebClient, copied to WebRequest.ContentType
- case "content-location":
- case "content-range":
- case "last-modified":
- case "accept": // accepted by WebClient, copied to HttpWebRequest.Accept
- case "accept-charset":
- case "accept-encoding":
- case "accept-language":
- case "cookie":
- case "expect":
- case "host":
- case "if-modified-since":
- case "max-forwards":
- case "referer":
- case "te":
- case "user-agent":
- // extra (not HttpRequestHeader defined) headers that are not accepted by SL2
- // note: the HttpResponseHeader enum is not available in SL2
- case "accept-ranges":
- case "age":
- case "allowed":
- case "connect":
- case "content-transfer-encoding":
- case "delete":
- case "etag":
- case "get":
- case "head":
- case "location":
- case "options":
- case "post":
- case "proxy-authenticate":
- case "proxy-connection":
- case "public":
- case "put":
- case "request-range":
- case "retry-after":
- case "server":
- case "sec-headertest":
- case "sec-":
- case "trace":
- case "uri":
- case "vary":
- case "www-authenticate":
- case "x-flash-version":
- string msg = String.Format ("'{0}' cannot be modified", header);
- throw new ArgumentException (msg, "header");
- default:
- return;
- }
- }
-
- internal static bool IsHeaderValue (string value)
- {
- // TEXT any 8 bit value except CTL's (0-31 and 127)
- // but including \r\n space and \t
- // after a newline at least one space or \t must follow
- // certain header fields allow comments ()
-
- int len = value.Length;
- for (int i = 0; i < len; i++) {
- char c = value [i];
- if (c == 127)
- return false;
- if (c < 0x20 && (c != '\r' && c != '\n' && c != '\t'))
- return false;
- if (c == '\r' && ++i < len) {
- c = value [i];
- if (c != '\n')
- return false;
- }
- if (c == '\n' && ++i < len) {
- c = value [i];
- if (c != ' ' && c != '\t')
- return false;
- }
- }
-
- return true;
- }
-
- internal static bool IsHeaderName (string name)
- {
- if (name == null || name.Length == 0)
- return false;
-
- int len = name.Length;
- for (int i = 0; i < len; i++) {
- char c = name [i];
- if (c > 126 || !allowed_chars [(int) c])
- return false;
- }
-
- return true;
- }
-
- static bool [] allowed_chars = new bool [126] {
- false, false, false, false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, true, false, true, true, true, true, false, false, false, true,
- true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, false,
- false, false, false, false, false, false, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
- false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
- false, true, false
- };
- }
-}
-
-#endif
+++ /dev/null
-//
-// System.Net.WebRequest (for 2.1 profile)
-//
-// Authors:
-// Jb Evain <jbevain@novell.com>
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2008-2010 Novell, Inc (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.Collections.Generic;
-using System.IO;
-
-namespace System.Net {
-
- public abstract class WebRequest {
-
- const string SystemWindows = "System.Windows, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB";
- const string BrowserStack = "System.Net.Browser.BrowserHttpWebRequestCreator, " + SystemWindows;
- const string ClientStack = "System.Net.Browser.ClientHttpWebRequestCreator, " + SystemWindows;
-
- static IWebRequestCreate default_creator;
- static IWebRequestCreate browser_creator;
- static IWebRequestCreate client_creator;
- static Dictionary<string, IWebRequestCreate> registred_prefixes;
-
- internal Action<long,long> progress;
-
- public abstract string ContentType { get; set; }
- public abstract WebHeaderCollection Headers { get; set; }
- public abstract string Method { get; set; }
- public abstract Uri RequestUri { get; }
-
- public virtual long ContentLength {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- // custom registered prefixes return null (unless they override this)
- public virtual IWebRequestCreate CreatorInstance {
- get { return null; }
- }
-
- public virtual ICredentials Credentials {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- public virtual bool UseDefaultCredentials {
- get { throw NotImplemented (); }
- set { throw NotImplemented (); }
- }
-
- static WebRequest ()
- {
- registred_prefixes = new Dictionary<string, IWebRequestCreate> (StringComparer.OrdinalIgnoreCase);
- browser_creator = (IWebRequestCreate) Activator.CreateInstance (Type.GetType (BrowserStack));
- client_creator = (IWebRequestCreate) Activator.CreateInstance (Type.GetType (ClientStack));
- default_creator = browser_creator;
- }
-
- protected WebRequest ()
- {
- }
-
- public abstract void Abort();
- public abstract IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state);
- public abstract IAsyncResult BeginGetResponse (AsyncCallback callback, object state);
- public abstract Stream EndGetRequestStream (IAsyncResult asyncResult);
- public abstract WebResponse EndGetResponse (IAsyncResult asyncResult);
-
- internal virtual IAsyncResult BeginGetResponse (AsyncCallback callback, object state, bool policy)
- {
- return BeginGetResponse (callback, state);
- }
-
- public static WebRequest Create (string requestUriString)
- {
- return Create (new Uri (requestUriString));
- }
-
- public static WebRequest Create (Uri requestUri)
- {
- if (requestUri == null)
- throw new ArgumentNullException ("requestUri");
- if (!requestUri.IsAbsoluteUri)
- throw new InvalidOperationException ("This operation is not supported for a relative URI.");
-
- IWebRequestCreate creator = null;
- int n = -1;
- // look for the most promising match in the registred prefixes
- foreach (KeyValuePair<string, IWebRequestCreate> kvp in registred_prefixes) {
- string key = kvp.Key;
- if ((key.Length > n) && requestUri.AbsoluteUri.StartsWith (key)) {
- creator = kvp.Value;
- n = key.Length;
- }
- }
-
- // 'http:/[/]' or 'https:/[/]' needs to be registred otherwise it gets ignored
- // note that this is unlike other protocols (e.g. 'ftp') - see unit tests
- string scheme = requestUri.Scheme;
- if ((scheme == "http" && n <= 5) || (scheme == "https" && n <= 6))
- creator = default_creator;
-
- if (creator == null)
- throw new NotSupportedException (string.Format ("Scheme {0} not supported", scheme));
-
- return creator.Create (requestUri);
- }
-
- public static HttpWebRequest CreateHttp (string requestUriString)
- {
- return CreateHttp (new Uri (requestUriString));
- }
-
- public static HttpWebRequest CreateHttp (Uri requestUri)
- {
- if (requestUri == null)
- throw new ArgumentNullException ("requestUri");
- if (!requestUri.IsAbsoluteUri)
- throw new InvalidOperationException ("Uri is not absolute.");
-
- // we do not check the registred prefixes from CreateHttp and *always* use the client HTTP stack
- switch (requestUri.Scheme) {
- case "http":
- case "https":
- return (HttpWebRequest) client_creator.Create (requestUri);
- default:
- throw new NotSupportedException (string.Format ("Scheme {0} not supported", requestUri.Scheme));
- }
- }
-
- // We can register for
- // * a protocol (e.g. http) for all requests
- // * a protocol (e.g. https) for a domain
- // * a protocol (e.g. http) for a single request
- //
- // See "How to: Specify Browser or Client HTTP Handling" for more details
- // http://msdn.microsoft.com/en-us/library/dd920295%28VS.95%29.aspx
- public static bool RegisterPrefix (string prefix, IWebRequestCreate creator)
- {
- if (prefix == null)
- throw new ArgumentNullException ("prefix");
- if (creator == null)
- throw new ArgumentNullException ("creator");
-
- Uri uri;
- if (Uri.TryCreate (prefix, UriKind.Absolute, out uri)) {
- // if a valid URI is supplied then only register the scheme + domain
- prefix = uri.Scheme + Uri.SchemeDelimiter + uri.DnsSafeHost;
- }
-
- // registering 'http', 'http://' or even 'http:/' are all ok - but *never* would 'http:' be correct!
- if ((String.Compare (prefix, "http:", StringComparison.OrdinalIgnoreCase) == 0) ||
- (String.Compare (prefix, "https:", StringComparison.OrdinalIgnoreCase) == 0))
- return false;
-
- if (registred_prefixes.ContainsKey (prefix))
- return false;
-
- registred_prefixes.Add (prefix, creator);
- return true;
- }
-
- static Exception NotImplemented ()
- {
- // hide the "normal" NotImplementedException from corcompare-like tools
- return new NotImplementedException ();
- }
- }
-}
-
-#endif
+++ /dev/null
-//
-// System.Net.HttpWebResponse (for 2.1 profile)
-//
-// Authors:
-// Jb Evain <jbevain@novell.com>
-//
-// (c) 2007 Novell, Inc. (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.IO;
-
-namespace System.Net {
-
- public abstract class WebResponse : IDisposable {
-
- private WebHeaderCollection headers;
-
- public abstract long ContentLength { get; }
- public abstract string ContentType { get; }
- public abstract Uri ResponseUri { get; }
-
- public virtual WebHeaderCollection Headers {
- get {
- if (!SupportsHeaders)
- throw NotImplemented ();
- return headers;
- }
- }
-
- internal WebHeaderCollection InternalHeaders {
- get { return headers; }
- set { headers = value; }
- }
-
- public virtual bool SupportsHeaders {
- get { return false; }
- }
-
- protected WebResponse ()
- {
- }
-
- public abstract void Close ();
- public abstract Stream GetResponseStream ();
-
- void IDisposable.Dispose ()
- {
- Close ();
- }
-
- static Exception NotImplemented ()
- {
- // hide the "normal" NotImplementedException from corcompare-like tools
- return new NotImplementedException ();
- }
- }
-}
-
-#endif
+++ /dev/null
-//
-// WriteStreamClosedEventArgs.cs
-//
-// Author:
-// Rolf Bjarne Kvinge <RKvinge@novell.com>
-//
-// (C) 2009 Novell, Inc. (http://www.novell.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.ComponentModel;
-using System.IO;
-
-namespace System.Net
-{
- public class WriteStreamClosedEventArgs : EventArgs
- {
- Exception exception;
-
- internal WriteStreamClosedEventArgs (Exception exception)
- {
- this.exception = exception;
- }
-
- public Exception Error {
- get { return exception; }
- }
- }
-}
-
-#endif
+++ /dev/null
-//
-// WriteStreamClosedEventHandler.cs
-//
-// Author:
-// Rolf Bjarne Kvinge <RKvinge@novell.com>
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Net
-{
- public delegate void WriteStreamClosedEventHandler (object sender, WriteStreamClosedEventArgs e);
-}
-
-#endif
+++ /dev/null
-//
-// BasicHttpSecurity_2_1.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// Copyright (C) 2008 Novell, Inc. http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-using System.Net.Security;
-using System.ServiceModel.Channels;
-
-namespace System.ServiceModel
-{
- public sealed class BasicHttpSecurity
- {
- internal BasicHttpSecurity (BasicHttpSecurityMode mode)
- {
- this.mode = mode;
- }
-
- BasicHttpSecurityMode mode;
-
- public BasicHttpSecurityMode Mode {
- get { return mode; }
- set { mode = value; }
- }
- }
-}
+++ /dev/null
-namespace System.Security.Cryptography.X509Certificates {
-
- public class X509Certificate2 : X509Certificate {
- public X509Certificate2 (byte[] rawData)
- {
- }
- }
-
- public class X509Chain {
- public bool Build (X509Certificate2 cert)
- {
- return false;
- }
- }
-}
-
+++ /dev/null
-//
-// StrongNameManager.cs - StrongName Management
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2004,2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Reflection;
-
-namespace Mono.Security {
-
- internal class StrongNameManager {
-
- static public byte[] GetMappedPublicKey (byte[] token)
- {
- return token;
- }
-
- static public bool MustVerify (AssemblyName an)
- {
- return true;
- }
- }
-}
-
+++ /dev/null
-//
-// System.Security.Policy.Evidence
-//
-// Authors:
-// Sean MacIsaac (macisaac@ximian.com)
-// Nick Drochak (ndrochak@gol.com)
-// Jackson Harper (Jackson@LatitudeGeo.com)
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2001 Ximian, Inc.
-// Portions (C) 2003, 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-namespace System.Security.Policy {
-
- public sealed class Evidence {
- }
-}
-
-#endif
-
+++ /dev/null
-//
-// System.Security.CodeAccessPermission.cs
-//
-// Authors:
-// Miguel de Icaza (miguel@ximian.com)
-// Nick Drochak, ndrochak@gol.com
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2001 Nick Drochak, All Rights Reserved
-// Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Security {
-
- public abstract class CodeAccessPermission {
- }
-}
-
+++ /dev/null
-//
-// System.Security.PermissionSet.cs
-//
-// Authors:
-// Nick Drochak(ndrochak@gol.com)
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) Nick Drochak
-// Portions (C) 2003, 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Security.Permissions;
-using System.Security.Policy;
-using System.Text;
-using System.Threading;
-
-namespace System.Security {
-
- [Serializable]
- public class PermissionSet {
-
- public PermissionSet ()
- {
- }
-
- public PermissionSet (PermissionState state)
- {
- }
-
- public PermissionSet (PermissionSet permSet)
- {
- }
-
- public IPermission AddPermission (IPermission perm)
- {
- return perm;
- }
-
- public bool IsUnrestricted ()
- {
- return true;
- }
-
- public PermissionSet Union (PermissionSet other)
- {
- return new PermissionSet ();
- }
- }
-}
+++ /dev/null
-//
-// System.Security.SecurityException.cs
-//
-// Authors:
-// Nick Drochak(ndrochak@gol.com)
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) Nick Drochak
-// (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005,2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-namespace System.Security {
-
- [ComVisible (true)]
- public class SecurityException : SystemException {
-
-
- public SecurityException ()
- : base (Locale.GetText ("A security error has been detected."))
- {
- base.HResult = unchecked ((int)0x8013150A);
- }
-
- public SecurityException (string message)
- : base (message)
- {
- base.HResult = unchecked ((int)0x8013150A);
- }
-
- public SecurityException (string message, Exception inner)
- : base (message, inner)
- {
- base.HResult = unchecked ((int)0x8013150A);
- }
-
- public override string ToString ()
- {
- return base.ToString ();
- }
- }
-}
+++ /dev/null
-//
-// System.AppDomainManager class
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2004-2005,2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if MOBILE
-
-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace System {
-
-#if MONO_FEATURE_MULTIPLE_APPDOMAINS
- [ComVisible (true)]
- public class AppDomainManager {
-
- public AppDomainManager ()
- {
- }
-
- [MonoTODO]
- public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo)
- {
- }
-
- [MonoTODO]
- public virtual bool CheckSecuritySettings (SecurityState state)
- {
- return (state != null);
- }
- }
-#else
- [Obsolete ("AppDomainManager is not supported on the current platform.", true)]
- public class AppDomainManager {
-
- public AppDomainManager ()
- {
- get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); }
- }
-
- public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo)
- {
- get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); }
- }
-
- public virtual bool CheckSecuritySettings (SecurityState state)
- {
- get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); }
- }
- }
-#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
-}
-
-#endif
-