Merge pull request #829 from symform/httpwebreq-async-ssl
[mono.git] / mcs / class / System / System.Net / NetworkCredential.cs
index 5eea32028f2b8ecbbdd6eaf588d3214ad00470c3..71f9f5b2689cad22d3c6ffe73dc2e3c192d441b8 100644 (file)
@@ -2,10 +2,11 @@
 // System.Net.NetworkCredential.cs
 //
 // Author: Duncan Mak (duncan@ximian.com)
+// Author: Rolf Bjarne KVinge (rolf@xamarin.com)
 //
 // (C) Ximian, Inc.
-//
-
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2011 Xamarin Inc (http://www.xamarin.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.Security;
+
 namespace System.Net
 {
        public class NetworkCredential : ICredentials
-#if NET_2_0
                                        , ICredentialsByHost
-#endif
        {
                // Fields
                string userName;
                string password;
                string domain;
                
+#if NET_4_0
+               SecureString securePassword;
+#endif
+
                // Constructors
                public NetworkCredential ()
-                       : base ()
                {
                }
 
@@ -60,34 +64,42 @@ namespace System.Net
 
                // Properties
 
-               public string Domain
-               {
-                       get { return domain; }
+               public string Domain {
+                       get { return domain ?? String.Empty; }
                        set { domain = value; }
                }
 
-               public string UserName
-               {
-                       get { return userName; }
+               public string UserName {
+                       get { return userName ?? String.Empty; }
                        set { userName = value; }                       
                }
 
-               public string Password
-               {
-                       get { return password; }
+               public string Password {
+                       get { return password ?? String.Empty; }
                        set { password = value; }
                }
 
+#if NET_4_0
+               public SecureString SecurePassword {
+                       get { return securePassword; }
+                       set {
+                               if (value == null) {
+                                       securePassword = new SecureString ();
+                               } else {
+                                       securePassword = value;
+                               }
+                       }
+               }
+#endif
+
                public NetworkCredential GetCredential (Uri uri, string authType)
                {
                        return this;
                }
 
-#if NET_2_0
                public NetworkCredential GetCredential (string host, int port, string authenticationType)
                {
                        return this;
                }
-#endif
        }
 }