IsReadOnly() 공개 메소드

public IsReadOnly ( ) : bool
리턴 bool
예제 #1
0
		public unsafe void UnsafeConstructor ()
		{
			try {
				SecureString ss = null;
				char[] data = new char[] { 'a', 'b', 'c' };
				fixed (char* p = &data[0]) {
					ss = new SecureString (p, data.Length);
				}
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (3, ss.Length, "3");
				ss.AppendChar ('a');
				Assert.AreEqual (4, ss.Length, "4");
				ss.Clear ();
				Assert.AreEqual (0, ss.Length, "0b");
				ss.InsertAt (0, 'b');
				Assert.AreEqual (1, ss.Length, "1b");
				ss.SetAt (0, 'c');
				Assert.AreEqual (1, ss.Length, "1c");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
예제 #2
0
        //
        // PUBLIC CONSTRUCTOR
        //

        // SqlCredential
        //  userId: userId
        //  password: password
        //
        public SqlCredential(string userId, SecureString password)
        {
            if (userId == null)
            {
                throw ADP.ArgumentNull("userId");
            }

            if (userId.Length > TdsEnums.MAXLEN_USERNAME)
            {
                throw ADP.InvalidArgumentLength("userId", TdsEnums.MAXLEN_USERNAME);
            }

            if (password == null)
            {
                throw ADP.ArgumentNull("password");
            }

            if (password.Length > TdsEnums.MAXLEN_PASSWORD)
            {
                throw ADP.InvalidArgumentLength("password", TdsEnums.MAXLEN_PASSWORD);
            }

            if (!password.IsReadOnly())
            {
                throw ADP.MustBeReadOnly("password");
            }

            _userId = userId;
            _password = password;
        }
예제 #3
0
		public void Set(string host, int port, string userName, SecureString password)
		{
			this.Host = host;
			this.Port = port;
			this.UserName = userName;

			if (this.Password != null) this.Password.Dispose();
			if (!password.IsReadOnly()) password.MakeReadOnly();
			this.Password = password;
		}
예제 #4
0
 public static string GetSecureStringValue(SecureString value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (!value.IsReadOnly())
     {
         throw new ArgumentException("SecureString must be read only.", "value");
     }
     IntPtr ustr = IntPtr.Zero;
     try
     {
         ustr = Marshal.SecureStringToBSTR(value);
         return Marshal.PtrToStringBSTR(ustr);
     }
     finally
     {
         Marshal.FreeBSTR(ustr);
     }
 }
예제 #5
0
		public void DefaultConstructor ()
		{
			try {
				SecureString ss = new SecureString ();
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (0, ss.Length, "0");
				ss.AppendChar ('a');
				Assert.AreEqual (1, ss.Length, "1");
				ss.Clear ();
				Assert.AreEqual (0, ss.Length, "0b");
				ss.InsertAt (0, 'b');
				Assert.AreEqual (1, ss.Length, "1b");
				ss.SetAt (0, 'c');
				Assert.AreEqual (1, ss.Length, "1c");
				Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
예제 #6
0
        // internal AND protected
        internal void WritePassword(SecureString password)
        {
            if (_process == null)
                return;

            if (!password.IsReadOnly())
                throw new GpgApiException("The SecureString \"password\" must be readonly");

            using (SecureStringToCharArrayMarshaler m = new SecureStringToCharArrayMarshaler(password))
            {
                _process.StandardInput.Write(m.Value);
                _process.StandardInput.WriteLine();
            }
        }