Moved the safe handles for credentials and contexts into their own file.
This commit is contained in:
27
Contexts/SafeContextHandle.cs
Normal file
27
Contexts/SafeContextHandle.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NSspi.Contexts
|
||||||
|
{
|
||||||
|
|
||||||
|
public class SafeContextHandle : SafeSspiHandle
|
||||||
|
{
|
||||||
|
public SafeContextHandle()
|
||||||
|
: base()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected override bool ReleaseHandle()
|
||||||
|
{
|
||||||
|
SecurityStatus status = ContextNativeMethods.DeleteSecurityContext(
|
||||||
|
ref base.rawHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
base.ReleaseHandle();
|
||||||
|
|
||||||
|
return status == SecurityStatus.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Credentials/SafeCredentialHandle.cs
Normal file
28
Credentials/SafeCredentialHandle.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NSspi.Credentials
|
||||||
|
{
|
||||||
|
|
||||||
|
public class SafeCredentialHandle : SafeSspiHandle
|
||||||
|
{
|
||||||
|
public SafeCredentialHandle()
|
||||||
|
: base()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected override bool ReleaseHandle()
|
||||||
|
{
|
||||||
|
SecurityStatus status = CredentialNativeMethods.FreeCredentialsHandle(
|
||||||
|
ref base.rawHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
base.ReleaseHandle();
|
||||||
|
|
||||||
|
return status == SecurityStatus.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
<Compile Include="Contexts\ContextNativeMethods.cs" />
|
<Compile Include="Contexts\ContextNativeMethods.cs" />
|
||||||
<Compile Include="Contexts\ContextQueries.cs" />
|
<Compile Include="Contexts\ContextQueries.cs" />
|
||||||
<Compile Include="Contexts\ContextQueryAttrib.cs" />
|
<Compile Include="Contexts\ContextQueryAttrib.cs" />
|
||||||
|
<Compile Include="Contexts\SafeContextHandle.cs" />
|
||||||
<Compile Include="Contexts\ServerContext.cs" />
|
<Compile Include="Contexts\ServerContext.cs" />
|
||||||
<Compile Include="Credentials\ClientCredential.cs" />
|
<Compile Include="Credentials\ClientCredential.cs" />
|
||||||
<Compile Include="Credentials\Credential.cs" />
|
<Compile Include="Credentials\Credential.cs" />
|
||||||
@@ -62,6 +63,7 @@
|
|||||||
<Compile Include="Credentials\CredentialType.cs" />
|
<Compile Include="Credentials\CredentialType.cs" />
|
||||||
<Compile Include="Credentials\CredentialUse.cs" />
|
<Compile Include="Credentials\CredentialUse.cs" />
|
||||||
<Compile Include="Credentials\QueryNameSupport.cs" />
|
<Compile Include="Credentials\QueryNameSupport.cs" />
|
||||||
|
<Compile Include="Credentials\SafeCredentialHandle.cs" />
|
||||||
<Compile Include="Credentials\ServerCredential.cs" />
|
<Compile Include="Credentials\ServerCredential.cs" />
|
||||||
<Compile Include="NativeMethods.cs" />
|
<Compile Include="NativeMethods.cs" />
|
||||||
<Compile Include="PackageNames.cs" />
|
<Compile Include="PackageNames.cs" />
|
||||||
|
|||||||
@@ -66,40 +66,4 @@ namespace NSspi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SafeCredentialHandle : SafeSspiHandle
|
|
||||||
{
|
|
||||||
public SafeCredentialHandle()
|
|
||||||
: base()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
protected override bool ReleaseHandle()
|
|
||||||
{
|
|
||||||
SecurityStatus status = CredentialNativeMethods.FreeCredentialsHandle(
|
|
||||||
ref base.rawHandle
|
|
||||||
);
|
|
||||||
|
|
||||||
base.ReleaseHandle();
|
|
||||||
|
|
||||||
return status == SecurityStatus.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SafeContextHandle : SafeSspiHandle
|
|
||||||
{
|
|
||||||
public SafeContextHandle()
|
|
||||||
: base()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
protected override bool ReleaseHandle()
|
|
||||||
{
|
|
||||||
SecurityStatus status = ContextNativeMethods.DeleteSecurityContext(
|
|
||||||
ref base.rawHandle
|
|
||||||
);
|
|
||||||
|
|
||||||
base.ReleaseHandle();
|
|
||||||
|
|
||||||
return status == SecurityStatus.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user