@@ -25,15 +25,15 @@ internal class ReflectedNegotiateState : INegotiateState
25
25
private static readonly FieldInfo _statusCode ;
26
26
private static readonly FieldInfo _statusException ;
27
27
private static readonly MethodInfo _getException ;
28
- private static readonly FieldInfo _gssMinorStatus ;
29
- private static readonly Type _gssExceptionType ;
28
+ private static readonly FieldInfo ? _gssMinorStatus ;
29
+ private static readonly Type ? _gssExceptionType ;
30
30
31
31
private readonly object _instance ;
32
32
33
33
static ReflectedNegotiateState ( )
34
34
{
35
35
var secAssembly = typeof ( AuthenticationException ) . Assembly ;
36
- var ntAuthType = secAssembly . GetType ( "System.Net.NTAuthentication" , throwOnError : true ) ;
36
+ var ntAuthType = secAssembly . GetType ( "System.Net.NTAuthentication" , throwOnError : true ) ! ;
37
37
_constructor = ntAuthType . GetConstructors ( BindingFlags . NonPublic | BindingFlags . Instance ) . First ( ) ;
38
38
_getOutgoingBlob = ntAuthType . GetMethods ( BindingFlags . NonPublic | BindingFlags . Instance ) . Where ( info =>
39
39
info . Name . Equals ( "GetOutgoingBlob" ) && info . GetParameters ( ) . Count ( ) == 3 ) . Single ( ) ;
@@ -44,19 +44,19 @@ static ReflectedNegotiateState()
44
44
_closeContext = ntAuthType . GetMethods ( BindingFlags . NonPublic | BindingFlags . Instance ) . Where ( info =>
45
45
info . Name . Equals ( "CloseContext" ) ) . Single ( ) ;
46
46
47
- var securityStatusType = secAssembly . GetType ( "System.Net.SecurityStatusPal" , throwOnError : true ) ;
48
- _statusCode = securityStatusType . GetField ( "ErrorCode" ) ;
49
- _statusException = securityStatusType . GetField ( "Exception" ) ;
47
+ var securityStatusType = secAssembly . GetType ( "System.Net.SecurityStatusPal" , throwOnError : true ) ! ;
48
+ _statusCode = securityStatusType . GetField ( "ErrorCode" ) ! ;
49
+ _statusException = securityStatusType . GetField ( "Exception" ) ! ;
50
50
51
51
if ( ! OperatingSystem . IsWindows ( ) )
52
52
{
53
- var interopType = secAssembly . GetType ( "Interop" , throwOnError : true ) ;
54
- var netNativeType = interopType . GetNestedType ( "NetSecurityNative" , BindingFlags . NonPublic | BindingFlags . Static ) ;
55
- _gssExceptionType = netNativeType . GetNestedType ( "GssApiException" , BindingFlags . NonPublic ) ;
56
- _gssMinorStatus = _gssExceptionType . GetField ( "_minorStatus" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
53
+ var interopType = secAssembly . GetType ( "Interop" , throwOnError : true ) ! ;
54
+ var netNativeType = interopType . GetNestedType ( "NetSecurityNative" , BindingFlags . NonPublic | BindingFlags . Static ) ! ;
55
+ _gssExceptionType = netNativeType . GetNestedType ( "GssApiException" , BindingFlags . NonPublic ) ! ;
56
+ _gssMinorStatus = _gssExceptionType . GetField ( "_minorStatus" , BindingFlags . Instance | BindingFlags . NonPublic ) ! ;
57
57
}
58
58
59
- var negoStreamPalType = secAssembly . GetType ( "System.Net.Security.NegotiateStreamPal" , throwOnError : true ) ;
59
+ var negoStreamPalType = secAssembly . GetType ( "System.Net.Security.NegotiateStreamPal" , throwOnError : true ) ! ;
60
60
_getIdentity = negoStreamPalType . GetMethods ( BindingFlags . NonPublic | BindingFlags . Static ) . Where ( info =>
61
61
info . Name . Equals ( "GetIdentity" ) ) . Single ( ) ;
62
62
_getException = negoStreamPalType . GetMethods ( BindingFlags . NonPublic | BindingFlags . Static ) . Where ( info =>
@@ -67,24 +67,24 @@ public ReflectedNegotiateState()
67
67
{
68
68
// internal NTAuthentication(bool isServer, string package, NetworkCredential credential, string spn, ContextFlagsPal requestedContextFlags, ChannelBinding channelBinding)
69
69
var credential = CredentialCache . DefaultCredentials ;
70
- _instance = _constructor . Invoke ( new object [ ] { true , "Negotiate" , credential , null , 0 , null } ) ;
70
+ _instance = _constructor . Invoke ( new object ? [ ] { true , "Negotiate" , credential , null , 0 , null } ) ;
71
71
}
72
72
73
73
// Copied rather than reflected to remove the IsCompleted -> CloseContext check.
74
74
// The client doesn't need the context once auth is complete, but the server does.
75
75
// I'm not sure why it auto-closes for the client given that the client closes it just a few lines later.
76
76
// https://github.com/dotnet/corefx/blob/a3ab91e10045bb298f48c1d1f9bd5b0782a8ac46/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs#L134
77
- public string GetOutgoingBlob ( string incomingBlob , out BlobErrorType status , out Exception error )
77
+ public string ? GetOutgoingBlob ( string incomingBlob , out BlobErrorType status , out Exception ? error )
78
78
{
79
- byte [ ] decodedIncomingBlob = null ;
79
+ byte [ ] ? decodedIncomingBlob = null ;
80
80
if ( incomingBlob != null && incomingBlob . Length > 0 )
81
81
{
82
82
decodedIncomingBlob = Convert . FromBase64String ( incomingBlob ) ;
83
83
}
84
84
85
85
byte [ ] decodedOutgoingBlob = GetOutgoingBlob ( decodedIncomingBlob , out status , out error ) ;
86
86
87
- string outgoingBlob = null ;
87
+ string ? outgoingBlob = null ;
88
88
if ( decodedOutgoingBlob != null && decodedOutgoingBlob . Length > 0 )
89
89
{
90
90
outgoingBlob = Convert . ToBase64String ( decodedOutgoingBlob ) ;
@@ -93,28 +93,28 @@ public string GetOutgoingBlob(string incomingBlob, out BlobErrorType status, out
93
93
return outgoingBlob ;
94
94
}
95
95
96
- private byte [ ] GetOutgoingBlob ( byte [ ] incomingBlob , out BlobErrorType status , out Exception error )
96
+ private byte [ ] GetOutgoingBlob ( byte [ ] ? incomingBlob , out BlobErrorType status , out Exception ? error )
97
97
{
98
98
try
99
99
{
100
100
// byte[] GetOutgoingBlob(byte[] incomingBlob, bool throwOnError, out SecurityStatusPal statusCode)
101
- var parameters = new object [ ] { incomingBlob , false , null } ;
102
- var blob = ( byte [ ] ) _getOutgoingBlob . Invoke ( _instance , parameters ) ;
101
+ var parameters = new object ? [ ] { incomingBlob , false , null } ;
102
+ var blob = ( byte [ ] ) _getOutgoingBlob . Invoke ( _instance , parameters ) ! ;
103
103
104
104
var securityStatus = parameters [ 2 ] ;
105
105
// TODO: Update after corefx changes
106
- error = ( Exception ) ( _statusException . GetValue ( securityStatus )
106
+ error = ( Exception ? ) ( _statusException . GetValue ( securityStatus )
107
107
?? _getException . Invoke ( null , new [ ] { securityStatus } ) ) ;
108
- var errorCode = ( SecurityStatusPalErrorCode ) _statusCode . GetValue ( securityStatus ) ;
108
+ var errorCode = ( SecurityStatusPalErrorCode ) _statusCode . GetValue ( securityStatus ) ! ;
109
109
110
110
// TODO: Remove after corefx changes
111
111
// The linux implementation always uses InternalError;
112
112
if ( errorCode == SecurityStatusPalErrorCode . InternalError
113
113
&& ! OperatingSystem . IsWindows ( )
114
- && _gssExceptionType . IsInstanceOfType ( error ) )
114
+ && _gssExceptionType ! . IsInstanceOfType ( error ) )
115
115
{
116
116
var majorStatus = ( uint ) error . HResult ;
117
- var minorStatus = ( uint ) _gssMinorStatus . GetValue ( error ) ;
117
+ var minorStatus = ( uint ) _gssMinorStatus ! . GetValue ( error ) ! ;
118
118
119
119
// Remap specific errors
120
120
if ( majorStatus == GSS_S_NO_CRED && minorStatus == 0 )
@@ -149,24 +149,24 @@ private byte[] GetOutgoingBlob(byte[] incomingBlob, out BlobErrorType status, ou
149
149
catch ( TargetInvocationException tex )
150
150
{
151
151
// Unwrap
152
- ExceptionDispatchInfo . Capture ( tex . InnerException ) . Throw ( ) ;
152
+ ExceptionDispatchInfo . Capture ( tex . InnerException ! ) . Throw ( ) ;
153
153
throw ;
154
154
}
155
155
}
156
156
157
157
public bool IsCompleted
158
158
{
159
- get => ( bool ) _isCompleted . Invoke ( _instance , Array . Empty < object > ( ) ) ;
159
+ get => ( bool ) _isCompleted . Invoke ( _instance , Array . Empty < object > ( ) ) ! ;
160
160
}
161
161
162
162
public string Protocol
163
163
{
164
- get => ( string ) _protocol . Invoke ( _instance , Array . Empty < object > ( ) ) ;
164
+ get => ( string ) _protocol . Invoke ( _instance , Array . Empty < object > ( ) ) ! ;
165
165
}
166
166
167
167
public IIdentity GetIdentity ( )
168
168
{
169
- return ( IIdentity ) _getIdentity . Invoke ( obj : null , parameters : new object [ ] { _instance } ) ;
169
+ return ( IIdentity ) _getIdentity . Invoke ( obj : null , parameters : new object [ ] { _instance } ) ! ;
170
170
}
171
171
172
172
public void Dispose ( )
0 commit comments