diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-04-29 19:38:46 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-04-30 02:26:43 +0300 |
commit | 3b33c55af76fb40f4f53dac76fdd294538046a2a (patch) | |
tree | a360b8079c354fd94973c774644203fb656fdff4 /main/src/addins/WindowsPlatform | |
parent | 798e2107a5a4534ba79dde831544ac9727f240ab (diff) |
[Core] Windows and Mac implementation of PasswordProvider removal.
Diffstat (limited to 'main/src/addins/WindowsPlatform')
-rw-r--r-- | main/src/addins/WindowsPlatform/WindowsPlatform/WindowsSecureStoragePasswordProvider.cs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsSecureStoragePasswordProvider.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsSecureStoragePasswordProvider.cs index 87cd6f5008..ec2cf59f97 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsSecureStoragePasswordProvider.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsSecureStoragePasswordProvider.cs @@ -119,14 +119,36 @@ namespace MonoDevelop.Platform.Windows }
}
+ static bool RemoveCredential (string targetName)
+ {
+ if (targetName == null)
+ throw new ArgumentNullException ("targetName");
+
+ return NativeMethods.CredDelete (targetName, NativeCredentialType.Generic, 0);
+ }
+
public void RemoveWebPassword (Uri uri)
{
- throw new NotImplementedException ();
+ RemoveWebUserNameAndPassword (uri);
}
public void RemoveWebUserNameAndPassword (Uri uri)
{
- throw new NotImplementedException ();
+ var didDelete = RemoveCredential (uri.Host);
+ if (didDelete) return;
+
+ var lastError = (ErrorCode)Marshal.GetLastWin32Error ();
+ switch (lastError) {
+ case ErrorCode.NoSuchLogonSession:
+ LoggingService.LogError ("Tried saving credentials, but the logon session does not exist.");
+ break;
+ case ErrorCode.InvalidFlags:
+ LoggingService.LogError ("Tried saving credentials, but got invalid flags set on credential.");
+ break;
+ default:
+ LoggingService.LogError ("Tried saving credentials, but got unknown error code 0x{0:X}.", lastError);
+ break;
+ }
}
}
@@ -273,5 +295,8 @@ namespace MonoDevelop.Platform.Windows [DllImport (ADVAPI32, CharSet = CharSet.Unicode, EntryPoint = "CredFree")]
internal static extern bool CredFree ([In] IntPtr cred);
+
+ [DllImport (ADVAPI32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "CredDeleteW")]
+ internal static extern bool CredDelete (string targetName, NativeCredentialType type, CredentialFlags flags);
}
}
|