Exemple #1
0
        internal static ExportedSecurityContext ExportContext(SecHandle context, SecPkgContextExportFlags export_flags, string package, bool client)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            SecBuffer buffer = new SecBuffer()
            {
                BufferType = SecurityBufferType.Empty
            };

            try
            {
                SecurityNativeMethods.ExportSecurityContext(context, export_flags,
                                                            buffer, out SafeKernelObjectHandle token).CheckResult();
                return(new ExportedSecurityContext(package, buffer.ToArray(), !token.IsInvalid ? NtToken.FromHandle(token) : null, client));
            }
            finally
            {
                if (buffer.pvBuffer != IntPtr.Zero)
                {
                    SecurityNativeMethods.FreeContextBuffer(buffer.pvBuffer);
                }
            }
        }
 internal override void FromBuffer(SecBuffer buffer)
 {
     if (Type.HasFlagSet(SecurityBufferType.ReadOnly | SecurityBufferType.ReadOnlyWithChecksum))
     {
         return;
     }
     _array = new ArraySegment <byte>(buffer.ToArray());
 }
Exemple #3
0
 internal static ExportedSecurityContext ExportContext(SecHandle context, SecPkgContextExportFlags export_flags, string package)
 {
     using (SecBuffer buffer = new SecBuffer(SecurityBufferType.Empty, 64 * 1024))
     {
         SecurityNativeMethods.ExportSecurityContext(context, SecPkgContextExportFlags.None,
                                                     buffer, out SafeKernelObjectHandle token).CheckResult();
         return(new ExportedSecurityContext(package, buffer.ToArray(), NtToken.FromHandle(token)));
     }
 }
Exemple #4
0
 internal override void FromBuffer(SecBuffer buffer)
 {
     _array = buffer.ToArray();
     _size  = _array.Length;
     _type  = buffer.BufferType;
 }