From 619ec109caffab6bb9bfc4cc8110e0dc5c99f2f8 Mon Sep 17 00:00:00 2001 From: Kareem Zedan Date: Sun, 23 May 2021 14:56:03 +0100 Subject: [PATCH] change win32 to derived types --- .../Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs | 10 +++++----- .../System/Net/Security/NegotiateStreamPal.Windows.cs | 10 +++++----- .../src/System/Net/SecurityStatusAdapterPal.Windows.cs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs index 95763518c96ae..7fab4806b5f6d 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs @@ -27,7 +27,7 @@ internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(ISSPIInterf if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"arrayBase: {arrayBaseHandle}"); if (errorCode != 0) { - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } var securityPackages = new SecurityPackageInfoClass[moduleCount]; @@ -86,7 +86,7 @@ public static SafeFreeCredentials AcquireDefaultCredential(ISSPIInterface secMod if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireDefaultCredential), $"0x{errorCode:X}")); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } return outCredential; } @@ -101,7 +101,7 @@ public static SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface secMod if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } return credentialsHandle; @@ -118,7 +118,7 @@ public static unsafe SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } return outCredential; @@ -135,7 +135,7 @@ public static unsafe SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } return outCredential; diff --git a/src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Windows.cs b/src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Windows.cs index 4e4e0c672b496..2d50f9391a67d 100644 --- a/src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Windows.cs +++ b/src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Windows.cs @@ -43,7 +43,7 @@ internal static SafeFreeCredentials AcquireCredentialsHandle(string package, boo if (result != Interop.SECURITY_STATUS.OK) { if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(Interop.SspiCli.SspiEncodeStringsAsAuthIdentity), $"0x{(int)result:X}")); - throw new Win32Exception((int)result); + throw new HttpListenerException((int)result); } return SSPIWrapper.AcquireCredentialsHandle(GlobalSSPI.SSPIAuth, @@ -169,9 +169,9 @@ internal static SecurityStatusPal AcceptSecurityContext( return SecurityStatusAdapterPal.GetSecurityStatusPalFromInterop(winStatus); } - internal static Win32Exception CreateExceptionFromError(SecurityStatusPal statusCode) + internal static HttpListenerException CreateExceptionFromError(SecurityStatusPal statusCode) { - return new Win32Exception((int)SecurityStatusAdapterPal.GetInteropFromSecurityStatusPal(statusCode)); + return new HttpListenerException((int)SecurityStatusAdapterPal.GetInteropFromSecurityStatusPal(statusCode)); } internal static int VerifySignature(SafeDeleteContext securityContext, byte[] buffer, int offset, int count) @@ -213,7 +213,7 @@ internal static int VerifySignature(SafeDeleteContext securityContext, byte[] bu if (errorCode != 0) { NetEventSource.Info($"VerifySignature threw error: {errorCode.ToString("x", NumberFormatInfo.InvariantInfo)}"); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } // not sure why this is here - retained from Encrypt code above @@ -257,7 +257,7 @@ internal static int MakeSignature(SafeDeleteContext securityContext, byte[] buff if (errorCode != 0) { NetEventSource.Info($"MakeSignature threw error: {errorCode.ToString("x", NumberFormatInfo.InvariantInfo)}"); - throw new Win32Exception(errorCode); + throw new HttpListenerException(errorCode); } // return signed size diff --git a/src/libraries/Common/src/System/Net/SecurityStatusAdapterPal.Windows.cs b/src/libraries/Common/src/System/Net/SecurityStatusAdapterPal.Windows.cs index 3b01a15c6a3e7..74b3389f689a6 100644 --- a/src/libraries/Common/src/System/Net/SecurityStatusAdapterPal.Windows.cs +++ b/src/libraries/Common/src/System/Net/SecurityStatusAdapterPal.Windows.cs @@ -81,7 +81,7 @@ internal static SecurityStatusPal GetSecurityStatusPalFromInterop(Interop.SECURI if (attachException) { - return new SecurityStatusPal(statusCode, new Win32Exception((int)win32SecurityStatus)); + return new SecurityStatusPal(statusCode, new HttpListenerException((int)win32SecurityStatus)); } else {