Added more disposed checks.

This commit is contained in:
antiduh
2014-06-30 14:49:26 +00:00
parent 0070e94aed
commit 6ed1ab5f76
3 changed files with 38 additions and 7 deletions

View File

@@ -33,15 +33,20 @@ namespace NSspi.Contexts
SecureBuffer serverBuffer;
SecureBufferAdapter serverAdapter;
if ( (serverToken != null) && ( this.ContextHandle.IsInvalid ) )
if( this.Disposed )
{
throw new ObjectDisposedException( "ClientContext" );
}
else if( ( serverToken != null ) && ( this.ContextHandle.IsInvalid ) )
{
throw new InvalidOperationException( "Out-of-order usage detected - have a server token, but no previous client token had been created." );
}
else if ( (serverToken == null) && ( this.ContextHandle.IsInvalid == false ) )
else if( ( serverToken == null ) && ( this.ContextHandle.IsInvalid == false ) )
{
throw new InvalidOperationException( "Must provide the server's response when continuing the init process." );
}
outTokenBuffer = new SecureBuffer( new byte[12288], BufferType.Token );

View File

@@ -35,6 +35,11 @@ namespace NSspi.Contexts
SecureBufferAdapter clientAdapter;
SecureBufferAdapter outAdapter;
if( this.Disposed )
{
throw new ObjectDisposedException( "ServerContext" );
}
using ( clientAdapter = new SecureBufferAdapter( clientBuffer ) )
{
using ( outAdapter = new SecureBufferAdapter( outBuffer ) )
@@ -112,7 +117,11 @@ namespace NSspi.Contexts
SecurityStatus status = SecurityStatus.InternalError;
bool gotRef = false;
if( impersonating )
if( this.Disposed )
{
throw new ObjectDisposedException( "ServerContext" );
}
else if( impersonating )
{
throw new InvalidOperationException( "Cannot impersonate again while already impersonating." );
}

View File

@@ -126,12 +126,19 @@ namespace NSspi.Credentials
{
get
{
QueryNameAttribCarrier carrier = new QueryNameAttribCarrier();
SecurityStatus status = SecurityStatus.InternalError;
QueryNameAttribCarrier carrier;
SecurityStatus status;
string name = null;
bool gotRef = false;
if( this.disposed )
{
throw new ObjectDisposedException( "Credential" );
}
status = SecurityStatus.InternalError;
carrier = new QueryNameAttribCarrier();
RuntimeHelpers.PrepareConstrainedRegions();
try
{
@@ -185,6 +192,11 @@ namespace NSspi.Credentials
{
get
{
if( this.disposed )
{
throw new ObjectDisposedException( "Credential" );
}
return this.expiry;
}
}
@@ -193,6 +205,11 @@ namespace NSspi.Credentials
{
get
{
if( this.disposed )
{
throw new ObjectDisposedException( "Credential" );
}
return this.safeCredHandle;
}
}