2005-09-09 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 9 Sep 2005 17:11:18 +0000 (17:11 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 9 Sep 2005 17:11:18 +0000 (17:11 -0000)
* MailAttachment.cs: Added [Link|Inheritance]Demand for Minimal. Added
FileIOPermission for Read in the constructor. Added [Obsolete] in 2.0.
* MailEncoding.cs: Removed [Serializable] and added [Obsolete] in 2.0.
* MailFormat.cs: Removed [Serializable] and added [Obsolete] in 2.0.
* MailMessage.cs: Removed references to RelatedBodyParts (2.0). Added
[Link|Inheritance]Demand for Minimal. Added [Obsolete] in 2.0.
* MailMessageWrapper.cs: Removed references to RelatedBodyParts (2.0).
* MailPriority.cs: Removed [Serializable] in 2.0. No [Obsolete] ?
* SmtpClient.cs: Removed references to RelatedBodyParts (2.0).
* SmtpMail.cs: Added [Link|Inheritance]Demand for Minimal. Added
Demand for Medium on Send method.Added [Obsolete] in 2.0.

svn path=/trunk/mcs/; revision=49811

mcs/class/System.Web/System.Web.Mail/ChangeLog
mcs/class/System.Web/System.Web.Mail/MailAttachment.cs
mcs/class/System.Web/System.Web.Mail/MailEncoding.cs
mcs/class/System.Web/System.Web.Mail/MailFormat.cs
mcs/class/System.Web/System.Web.Mail/MailMessage.cs
mcs/class/System.Web/System.Web.Mail/MailMessageWrapper.cs
mcs/class/System.Web/System.Web.Mail/MailPriority.cs
mcs/class/System.Web/System.Web.Mail/SmtpClient.cs
mcs/class/System.Web/System.Web.Mail/SmtpMail.cs

index 8361593aab95b1a6de543ba504d266a27d9400b1..146c872fddffcb52ec3c5b4764411fde0242d202 100644 (file)
@@ -1,3 +1,17 @@
+2005-09-09  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * MailAttachment.cs: Added [Link|Inheritance]Demand for Minimal. Added
+       FileIOPermission for Read in the constructor. Added [Obsolete] in 2.0.
+       * MailEncoding.cs: Removed [Serializable] and added [Obsolete] in 2.0.
+       * MailFormat.cs: Removed [Serializable] and added [Obsolete] in 2.0.
+       * MailMessage.cs: Removed references to RelatedBodyParts (2.0). Added 
+       [Link|Inheritance]Demand for Minimal. Added [Obsolete] in 2.0.
+       * MailMessageWrapper.cs: Removed references to RelatedBodyParts (2.0).
+       * MailPriority.cs: Removed [Serializable] in 2.0. No [Obsolete] ?
+       * SmtpClient.cs: Removed references to RelatedBodyParts (2.0).
+       * SmtpMail.cs: Added [Link|Inheritance]Demand for Minimal. Added 
+       Demand for Medium on Send method.Added [Obsolete] in 2.0.
+
 2005-06-08 Ilya Kharmatsky <ilyak-at-mainsoft.com>
 
     * SmtpMail.cs: Added TARGET_JVM directive in Send method,
index 6232f12401139be3a86563b7ddd2bb4e41dfe7f5..453ed2cd042af03337441a85ecd0243304abc5ab 100644 (file)
@@ -3,9 +3,10 @@
 //\r
 // Author:\r
 //    Lawrence Pit (loz@cable.a2000.nl)\r
-//    Per Arneng (pt99par@student.bth.se)\r
+//    Per Arneng (pt99par@student.bth.se)
+//    Sebastien Pouliot  <sebastien@ximian.com>\r
 //\r
-
+// Copyright (C) 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
 // 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.Security.Permissions;
 \r
 namespace System.Web.Mail\r
 {\r
+       // CAS
+       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+       [Obsolete]
+#endif
        public class MailAttachment\r
        {\r
                private string filename;\r
@@ -40,15 +51,18 @@ namespace System.Web.Mail
                }\r
                \r
                public MailAttachment (string filename, MailEncoding encoding) \r
-               {\r
+               {
+                       if (SecurityManager.SecurityEnabled) {
+                               new FileIOPermission (FileIOPermissionAccess.Read, filename).Demand ();
+                       }
+
+                       if (!File.Exists (filename)) {
+                               string msg = Locale.GetText ("Cannot find file: '{0}'.");
+                               throw new HttpException (String.Format (msg, filename));\r
+                       }
+\r
                        this.filename = filename;\r
-                       this.encoding = encoding;\r
-                       try {\r
-                               System.IO.File.OpenRead (filename).Close ();\r
-                       } catch (Exception) {\r
-                           throw new System.Web.HttpException ("Cannot find file: '" + \r
-                                                               filename + "'." );\r
-                       }                       \r
+                       this.encoding = encoding;
                }\r
            \r
                // Properties\r
@@ -61,7 +75,5 @@ namespace System.Web.Mail
                {\r
                        get { return encoding; } \r
                }               \r
-       \r
        }\r
-       \r
-} //namespace System.Web.Mail\r
+}\r
index 161a31823a9832f34bfc0995707eb2bb02bf7b18..34eea8261b634c60d98d7c2e300ab492b42e6c88 100644 (file)
@@ -4,7 +4,7 @@
 // Author:\r
 //    Lawrence Pit (loz@cable.a2000.nl)\r
 //\r
-
+// Copyright (C) 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 \r
-namespace System.Web.Mail \r
-{\r
+namespace System.Web.Mail {
 \r
-       /// <summary>\r
-       /// </summary>\r
 #if NET_2_0
-       [Serializable]
+       [Obsolete]
 #endif
-       public enum MailEncoding \r
-       {\r
-\r
-               /// <summary>\r
-               /// </summary>\r
-               UUEncode = 0,\r
-\r
-               /// <summary>\r
-               /// </summary>\r
-               Base64 = 1\r
-\r
+       public enum MailEncoding {\r
+               UUEncode,\r
+               Base64\r
        } \r
-       \r
-} //namespace System.Web.Mail\r
+}\r
index 35a13d363bd25f6f6a55ddac9c20aa6381f62e2d..0fa0d399429456c9ec0e50d1a770b0d1a933434c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:\r
 //    Lawrence Pit (loz@cable.a2000.nl)\r
 //\r
-
+// Copyright (C) 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 \r
-namespace System.Web.Mail \r
-{\r
+namespace System.Web.Mail {
 \r
-       /// <summary>\r
-       /// </summary>\r
 #if NET_2_0
-        [Serializable]
+       [Obsolete]
 #endif
-       public enum MailFormat \r
-       {\r
-\r
-               /// <summary>\r
-               /// </summary>\r
-               Text = 0,\r
-       \r
-               /// <summary>\r
-               /// </summary>\r
-               Html = 1\r
-\r
+       public enum MailFormat {\r
+               Text,\r
+               Html\r
        } \r
-       \r
-} //namespace System.Web.Mail\r
+}
index cd0eb98f335acffd35fc1271e0376bbb180f0328..e91dd0e3426850e15eb1ccc32476a63ad4e41f3f 100644 (file)
@@ -6,9 +6,7 @@
 //    Per Arneng (pt99par@student.bth.se)\r
 //     Sanjay Gupta (gsanjay@novell.com)
 //
-//     (c)2004 Novell, Inc. (http://www.novell.com)
-//\r
-
+// 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 \r
-using System;\r
 using System.Collections;\r
 using System.Collections.Specialized;\r
+using System.Security.Permissions;
 using System.Text;\r
 \r
 namespace System.Web.Mail\r
 {\r
-       /// <remarks>\r
-       /// </remarks>\r
+       // CAS
+       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+       [Obsolete]
+#endif
        public class MailMessage\r
        {\r
                private ArrayList attachments;\r
                private string bcc;\r
-               private string body = "";\r
+               private string body = String.Empty;\r
                private Encoding bodyEncoding;\r
                private MailFormat bodyFormat;\r
                private string cc;              \r
                private string from;\r
                private ListDictionary headers;\r
                private MailPriority priority;\r
-               private string subject = "";\r
+               private string subject = String.Empty;\r
                private string to;\r
                private string urlContentBase;\r
                private string urlContentLocation;
@@ -63,9 +65,6 @@ namespace System.Web.Mail
                        bodyEncoding = Encoding.Default;
 #if NET_1_1
                        fields = new Hashtable ();\r
-#endif
-#if NET_2_0
-                       bodyParts = new ArrayList (2);
 #endif
                }               \r
        \r
@@ -142,15 +141,5 @@ namespace System.Web.Mail
                        }\r
                }\r
 #endif\r
-
-#if NET_2_0
-               private ArrayList bodyParts;
-               
-               public IList RelatedBodyParts {
-                       get { return (IList) bodyParts; }
-               }
-#endif
-
        }\r
-       \r
-} //namespace System.Web.Mail\r
+}\r
index f50ec10c7bdc5df331c7933729e54489b47465a1..d7ab68663da94bfffaf49807513c9f8599f46e7a 100644 (file)
@@ -247,11 +247,5 @@ namespace System.Web.Mail {
                        
                }
 #endif
-
-#if NET_2_0
-               public IList RelatedBodyParts {
-                       get { return message.RelatedBodyParts; }
-               }
-#endif
     }   
 }
index 5c0bf83ed2a45fe1aa8f81d9f848e0a56ff3e540..cb55649a18c148db536688a738e56b0c92f520ec 100644 (file)
@@ -4,7 +4,7 @@
 // Author:\r
 //    Lawrence Pit (loz@cable.a2000.nl)\r
 //\r
-
+// Copyright (C) 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 \r
-namespace System.Web.Mail \r
-{\r
-\r
-       /// <summary>\r
-       /// </summary>\r
-#if NET_2_0
-        [Serializable]
-#endif
-       public enum MailPriority \r
-       {\r
-\r
-               /// <summary>\r
-               /// </summary>\r
-               Normal = 0,\r
-               \r
-               /// <summary>\r
-               /// </summary>\r
-               Low = 1,\r
-\r
-               /// <summary>\r
-               /// </summary>\r
-               High = 2\r
-\r
+namespace System.Web.Mail {\r
+
+       public enum MailPriority {\r
+               Normal,\r
+               Low,\r
+               High\r
        } \r
-       \r
-} //namespace System.Web.Mail\r
+}\r
index e47401258199b86adbddfaf4993a6678052bc33e..f467392809fb5287b6c3fdc18a1b252e587b134b 100644 (file)
@@ -105,13 +105,7 @@ namespace System.Web.Mail {
            smtp.WriteData();
                
            if( msg.Attachments.Count == 0 ) {
-#if NET_2_0
-               //The message might be multipart, if RelatedBodyParts are present
-               if (msg.RelatedBodyParts.Count != 0)
-                       SendMultipartMail (msg);
-               else
-#endif         
-                       SendSinglepartMail( msg );          
+               SendSinglepartMail( msg );          
            } else {
                
                SendMultipartMail( msg );
@@ -143,11 +137,6 @@ namespace System.Web.Mail {
            // set the Content-Type header to multipart/mixed
            string bodyContentType = msg.Header.ContentType;
 
-#if NET_2_0
-               if (msg.RelatedBodyParts.Count != 0)
-                       msg.Header.ContentType = String.Format( "multipart/related;\r\n   boundary={0}" , boundary );
-               else
-#endif
            msg.Header.ContentType = 
                String.Format( "multipart/mixed;\r\n   boundary={0}" , boundary );
                
@@ -188,43 +177,6 @@ namespace System.Web.Mail {
 
            smtp.WriteBoundary( boundary );
 
-#if NET_2_0
-               for (int i = 0; i < msg.RelatedBodyParts.Count; i++) {
-                       RelatedBodyPart rbp = (RelatedBodyPart) msg.RelatedBodyParts [i];
-                       FileInfo file = new FileInfo (rbp.Path);
-                       MailHeader header = new MailHeader ();
-                       header.ContentLocation = rbp.Path;
-                       header.ContentType = String.Format (MimeTypes.GetMimeType (file.Name) + "; name=\"{0}\"",file.Name);
-                       //If content id and ContentLocation both are present
-                       //in mime header of a mail, than RelatedBodyPart of mail
-                       //doesnt show up in a machine other than from which mail
-                       //was sent, and hence only one of them is inserted in 
-                       //header. Need to check how the things go when another 
-                       //body part refers the content with the content id specified
-                       /*if (rbp.Name != null)
-                               header.Data.Add ("Content-ID", "<"+rbp.Name+">");*/
-                               
-                       header.ContentTransferEncoding = "Base64";
-                       header.ContentDisposition = String.Format( "inline; filename=\"{0}\"" , file.Name );
-                       
-                       smtp.WriteHeader (header);
-                       FileStream rbpStream = new FileStream (file.FullName, FileMode.Open);
-                       IAttachmentEncoder rbpEncoder = new Base64AttachmentEncoder ();
-                       rbpEncoder.EncodeStream (rbpStream, smtp.Stream);
-                       rbpStream.Close();
-                       smtp.WriteLine( "" );
-                       
-                       if (i < (msg.RelatedBodyParts.Count - 1)) {
-                               smtp.WriteBoundary (boundary);
-                       } else {
-                               if (msg.Attachments.Count == 0)
-                                        smtp.WriteFinalBoundary (boundary);
-                               else
-                                       smtp.WriteBoundary (boundary);
-                                       
-                       }                                               
-               }
-#endif     
            // now start to write the attachments
            
            for( int i=0; i< msg.Attachments.Count ; i++ ) {
index f547a2ca58c50df5dc0821b98764fecc32e36c02..d2774c0ca800a5262f2134963bd831ddfa871093 100644 (file)
@@ -5,7 +5,7 @@
 //    Lawrence Pit (loz@cable.a2000.nl)
 //    Per Arneng (pt99par@student.bth.se) (SmtpMail.Send)
 //
-
+// 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
 using System.IO;
 using System.Reflection;
+using System.Security.Permissions;
 
 namespace System.Web.Mail
 {
-       /// <remarks>
-       /// </remarks>
+       // CAS
+       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+       [Obsolete]
+#endif
        public class SmtpMail
        {
                private static string smtpServer = "localhost";
@@ -54,7 +58,9 @@ namespace System.Web.Mail
                        set { smtpServer = value; }
                }
                
-               
+               // Medium (not Minimal) here
+               // http://msdn.microsoft.com/library/en-us/dnpag2/html/paght000017.asp
+               [AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
                public static void Send (MailMessage message) 
                {
                                                    
@@ -112,7 +118,5 @@ namespace System.Web.Mail
                        message.Body = messageText;
                        Send (message);
                }
-       
        }
-       
-} //namespace System.Web.Mail
+}