当前位置: 首页>>代码示例>>C#>>正文


C# Security.SSPIInterface类代码示例

本文整理汇总了C#中System.Net.Security.SSPIInterface的典型用法代码示例。如果您正苦于以下问题:C# SSPIInterface类的具体用法?C# SSPIInterface怎么用?C# SSPIInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SSPIInterface类属于System.Net.Security命名空间,在下文中一共展示了SSPIInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetVerifyPackageInfo

        internal static SecurityPackageInfoClass GetVerifyPackageInfo(SSPIInterface secModule, string packageName, bool throwIfMissing)
        {
            SecurityPackageInfoClass[] supportedSecurityPackages = EnumerateSecurityPackages(secModule);
            if (supportedSecurityPackages != null)
            {
                for (int i = 0; i < supportedSecurityPackages.Length; i++)
                {
                    if (string.Compare(supportedSecurityPackages[i].Name, packageName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return supportedSecurityPackages[i];
                    }
                }
            }

            if (SecurityEventSource.Log.IsEnabled())
            {
                SecurityEventSource.Log.SspiPackageNotFound(packageName);
            }

            if (throwIfMissing)
            {
                throw new NotSupportedException(SR.net_securitypackagesupport);
            }

            return null;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:26,代码来源:SSPIWrapper.cs

示例2: GetVerifyPackageInfo

        internal static SecurityPackageInfoClass GetVerifyPackageInfo(SSPIInterface secModule, string packageName, bool throwIfMissing)
        {
            SecurityPackageInfoClass[] supportedSecurityPackages = EnumerateSecurityPackages(secModule);
            if (supportedSecurityPackages != null)
            {
                for (int i = 0; i < supportedSecurityPackages.Length; i++)
                {
                    if (string.Compare(supportedSecurityPackages[i].Name, packageName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return supportedSecurityPackages[i];
                    }
                }
            }

            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, SR.Format(SR.net_log_sspi_security_package_not_found, packageName));
            }

            if (throwIfMissing)
            {
                throw new NotSupportedException(SR.net_securitypackagesupport);
            }

            return null;
        }
开发者ID:natemcmaster,项目名称:corefx,代码行数:26,代码来源:SSPIWrapper.cs

示例3: EnumerateSecurityPackages

 internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface SecModule) {
     GlobalLog.Enter("EnumerateSecurityPackages");
     if (SecModule.SecurityPackages==null) {
         lock (SecModule) {
             if (SecModule.SecurityPackages==null) {
                 int moduleCount = 0;
                 SafeFreeContextBuffer arrayBaseHandle = null;
                 try {
                     int errorCode = SecModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                     GlobalLog.Print("SSPIWrapper::arrayBase: " + (arrayBaseHandle.DangerousGetHandle().ToString("x")));
                     if (errorCode != 0) {
                         throw new Win32Exception(errorCode);
                     }
                     SecurityPackageInfoClass[] securityPackages = new SecurityPackageInfoClass[moduleCount];
                     if (Logging.On) Logging.PrintInfo(Logging.Web, SR.GetString(SR.net_log_sspi_enumerating_security_packages));
                     int i;
                     for (i = 0; i < moduleCount; i++) {
                         securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                         if (Logging.On) Logging.PrintInfo(Logging.Web, "    " + securityPackages[i].Name);
                     }
                     SecModule.SecurityPackages = securityPackages;
                 }
                 finally {
                     if (arrayBaseHandle != null) {
                         arrayBaseHandle.Close();
                     }
                 }
             }
         }
     }
     GlobalLog.Leave("EnumerateSecurityPackages");
     return SecModule.SecurityPackages;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:_SSPIWrapper.cs

示例4: EnumerateSecurityPackages

        internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface secModule)
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Enter("EnumerateSecurityPackages");
            }

            if (secModule.SecurityPackages == null)
            {
                lock (secModule)
                {
                    if (secModule.SecurityPackages == null)
                    {
                        int moduleCount = 0;
                        SafeFreeContextBuffer arrayBaseHandle = null;
                        try
                        {
                            int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                            if (GlobalLog.IsEnabled)
                            {
                                GlobalLog.Print("SSPIWrapper::arrayBase: " + (arrayBaseHandle.DangerousGetHandle().ToString("x")));
                            }
                            if (errorCode != 0)
                            {
                                throw new Win32Exception(errorCode);
                            }

                            var securityPackages = new SecurityPackageInfoClass[moduleCount];

                            int i;
                            for (i = 0; i < moduleCount; i++)
                            {
                                securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                                if (SecurityEventSource.Log.IsEnabled())
                                {
                                    SecurityEventSource.Log.EnumerateSecurityPackages(securityPackages[i].Name);
                                }
                            }

                            secModule.SecurityPackages = securityPackages;
                        }
                        finally
                        {
                            if (arrayBaseHandle != null)
                            {
                                arrayBaseHandle.Dispose();
                            }
                        }
                    }
                }
            }

            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Leave("EnumerateSecurityPackages");
            }
            return secModule.SecurityPackages;
        }
开发者ID:nadiatk,项目名称:corefx,代码行数:58,代码来源:SSPIWrapper.cs

示例5: VerifyPackageInfo

        internal static void VerifyPackageInfo(SSPIInterface secModule)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, "VerifyPackageInfo");
            }

            secModule.VerifyPackageInfo();
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:9,代码来源:_SSPIWrapper.cs

示例6: AcceptSecurityContext

 internal static SecurityStatus AcceptSecurityContext(SSPIInterface SecModule, ref SafeFreeCredentials credential, ref SafeDeleteContext context, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, bool remoteCertRequired)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.Web,
             "AcceptSecurityContext(" +
             "credential = " + credential.ToString() + ", " +
             "context = " + Logging.ObjectToString(context) + ", " +
             "remoteCertRequired = " + remoteCertRequired);
     }
     return SecModule.AcceptSecurityContext(ref credential, ref context, inputBuffer, outputBuffer, remoteCertRequired);
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:12,代码来源:_SSPIWrapper.cs

示例7: AcquireCredentialsHandle

        internal static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface SecModule, X509Certificate certificate, SslProtocols protocols, EncryptionPolicy policy, bool isServer)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                    "AcquireCredentialsHandle(" +
                    "protocols  = " + protocols + ", " +
                    "policy   = " + policy + ", " +
                    "isServer = " + isServer + ")");
            }

            return SecModule.AcquireCredentialsHandle(certificate, protocols, policy, isServer);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:13,代码来源:_SSPIWrapper.cs

示例8: InitializeSecurityContext

        internal static SecurityStatus InitializeSecurityContext(SSPIInterface SecModule, SafeFreeCredentials credential, ref SafeDeleteContext context, string targetName, SecurityBuffer[] inputBuffers, SecurityBuffer outputBuffer)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                    "InitializeSecurityContext(" +
                    "credential = " + credential.ToString() + ", " +
                    "context = " + Logging.ObjectToString(context) + ", " +
                    "targetName = " + targetName);
            }

            SecurityStatus errorCode = SecModule.InitializeSecurityContext(credential, ref context, targetName, inputBuffers, outputBuffer);
           
            return errorCode;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:15,代码来源:_SSPIWrapper.cs

示例9: EnumerateSecurityPackages

        internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface secModule)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(null);

            if (secModule.SecurityPackages == null)
            {
                lock (secModule)
                {
                    if (secModule.SecurityPackages == null)
                    {
                        int moduleCount = 0;
                        SafeFreeContextBuffer arrayBaseHandle = null;
                        try
                        {
                            int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                            if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"arrayBase: {arrayBaseHandle}");
                            if (errorCode != 0)
                            {
                                throw new Win32Exception(errorCode);
                            }

                            var securityPackages = new SecurityPackageInfoClass[moduleCount];

                            int i;
                            for (i = 0; i < moduleCount; i++)
                            {
                                securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                                if (NetEventSource.IsEnabled) NetEventSource.Log.EnumerateSecurityPackages(securityPackages[i].Name);
                            }

                            secModule.SecurityPackages = securityPackages;
                        }
                        finally
                        {
                            if (arrayBaseHandle != null)
                            {
                                arrayBaseHandle.Dispose();
                            }
                        }
                    }
                }
            }

            if (NetEventSource.IsEnabled) NetEventSource.Exit(null);
            return secModule.SecurityPackages;
        }
开发者ID:jimcarley,项目名称:corefx,代码行数:46,代码来源:SSPIWrapper.cs

示例10: AcquireDefaultCredential

        public static SafeFreeCredentials AcquireDefaultCredential(SSPIInterface SecModule, string package, CredentialUse intent) {
            GlobalLog.Print("SSPIWrapper::AcquireDefaultCredential(): using " + package);
            if (Logging.On) Logging.PrintInfo(Logging.Web, 
                "AcquireDefaultCredential(" +
                "package = " + package + ", " +
                "intent  = " + intent + ")");


            SafeFreeCredentials outCredential = null;
            int errorCode = SecModule.AcquireDefaultCredential(package, intent, out outCredential );

            if (errorCode != 0) {
#if TRAVE
                GlobalLog.Print("SSPIWrapper::AcquireDefaultCredential(): error " + SecureChannel.MapSecurityStatus((uint)errorCode));
#endif
                if (Logging.On) Logging.PrintError(Logging.Web, SR.GetString(SR.net_log_operation_failed_with_error, "AcquireDefaultCredential()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                throw new Win32Exception(errorCode);
            }
            return outCredential;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:20,代码来源:_SSPIWrapper.cs

示例11: AcquireCredentialsHandle

        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.Secur32.CredentialUse intent, ref SafeSspiAuthDataHandle authdata)
        {
            if (SecurityEventSource.Log.IsEnabled())
            {
                SecurityEventSource.AcquireCredentialsHandle(package, intent, authdata);
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = secModule.AcquireCredentialsHandle(package, intent, ref authdata, out credentialsHandle);

            if (errorCode != 0)
            {
                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.PrintError(NetEventSource.ComponentType.Security, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }

            return credentialsHandle;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:22,代码来源:SSPIWrapper.cs

示例12: AcquireDefaultCredential

        public static SafeFreeCredentials AcquireDefaultCredential(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(null, package);
                NetEventSource.Log.AcquireDefaultCredential(package, intent);
            }

            SafeFreeCredentials outCredential = null;
            int errorCode = secModule.AcquireDefaultCredential(package, intent, out outCredential);

            if (errorCode != 0)
            {
                if (NetEventSource.IsEnabled) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireDefaultCredential), $"0x{errorCode:X}"));
                throw new Win32Exception(errorCode);
            }
            return outCredential;
        }
开发者ID:jimcarley,项目名称:corefx,代码行数:18,代码来源:SSPIWrapper.cs

示例13: QueryContextAttributes

        public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.Secur32.ContextAttribute contextAttribute, out int errorCode)
        {
            GlobalLog.Enter("QueryContextAttributes", contextAttribute.ToString());

            int nativeBlockSize = IntPtr.Size;
            Type handleType = null;

            switch (contextAttribute)
            {
                case Interop.Secur32.ContextAttribute.Sizes:
                    nativeBlockSize = SecSizes.SizeOf;
                    break;
                case Interop.Secur32.ContextAttribute.StreamSizes:
                    nativeBlockSize = StreamSizes.SizeOf;
                    break;

                case Interop.Secur32.ContextAttribute.Names:
                    handleType = typeof(SafeFreeContextBuffer);
                    break;

                case Interop.Secur32.ContextAttribute.PackageInfo:
                    handleType = typeof(SafeFreeContextBuffer);
                    break;

                case Interop.Secur32.ContextAttribute.NegotiationInfo:
                    handleType = typeof(SafeFreeContextBuffer);
                    nativeBlockSize = Marshal.SizeOf<NegotiationInfo>();
                    break;

                case Interop.Secur32.ContextAttribute.ClientSpecifiedSpn:
                    handleType = typeof(SafeFreeContextBuffer);
                    break;

                case Interop.Secur32.ContextAttribute.RemoteCertificate:
                    handleType = typeof(SafeFreeCertContext);
                    break;

                case Interop.Secur32.ContextAttribute.LocalCertificate:
                    handleType = typeof(SafeFreeCertContext);
                    break;

                case Interop.Secur32.ContextAttribute.IssuerListInfoEx:
                    nativeBlockSize = Marshal.SizeOf<Interop.Secur32.IssuerListInfoEx>();
                    handleType = typeof(SafeFreeContextBuffer);
                    break;

                case Interop.Secur32.ContextAttribute.ConnectionInfo:
                    nativeBlockSize = Marshal.SizeOf<SslConnectionInfo>();
                    break;

                default:
                    throw new ArgumentException(SR.Format(SR.net_invalid_enum, "ContextAttribute"), "contextAttribute");
            }

            SafeHandle sspiHandle = null;
            object attribute = null;

            try
            {
                byte[] nativeBuffer = new byte[nativeBlockSize];
                errorCode = secModule.QueryContextAttributes(securityContext, contextAttribute, nativeBuffer, handleType, out sspiHandle);
                if (errorCode != 0)
                {
                    GlobalLog.Leave("Win32:QueryContextAttributes", "ERROR = " + ErrorDescription(errorCode));
                    return null;
                }

                switch (contextAttribute)
                {
                    case Interop.Secur32.ContextAttribute.Sizes:
                        attribute = new SecSizes(nativeBuffer);
                        break;

                    case Interop.Secur32.ContextAttribute.StreamSizes:
                        attribute = new StreamSizes(nativeBuffer);
                        break;

                    case Interop.Secur32.ContextAttribute.Names:
                        attribute = Marshal.PtrToStringUni(sspiHandle.DangerousGetHandle());
                        break;

                    case Interop.Secur32.ContextAttribute.PackageInfo:
                        attribute = new SecurityPackageInfoClass(sspiHandle, 0);
                        break;

                    case Interop.Secur32.ContextAttribute.NegotiationInfo:
                        unsafe
                        {
                            fixed (void* ptr = nativeBuffer)
                            {
                                attribute = new NegotiationInfoClass(sspiHandle, Marshal.ReadInt32(new IntPtr(ptr), NegotiationInfo.NegotiationStateOffest));
                            }
                        }
                        break;

                    case Interop.Secur32.ContextAttribute.ClientSpecifiedSpn:
                        attribute = Marshal.PtrToStringUni(sspiHandle.DangerousGetHandle());
                        break;

                    case Interop.Secur32.ContextAttribute.LocalCertificate:
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:SSPIWrapper.cs

示例14: QueryContextChannelBinding

        public static SafeFreeContextBufferChannelBinding QueryContextChannelBinding(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.Secur32.ContextAttribute contextAttribute)
        {
            GlobalLog.Enter("QueryContextChannelBinding", contextAttribute.ToString());

            SafeFreeContextBufferChannelBinding result;
            int errorCode = secModule.QueryContextChannelBinding(securityContext, contextAttribute, out result);
            if (errorCode != 0)
            {
                GlobalLog.Leave("QueryContextChannelBinding", "ERROR = " + ErrorDescription(errorCode));
                return null;
            }

            GlobalLog.Leave("QueryContextChannelBinding", LoggingHash.HashString(result));
            return result;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:15,代码来源:SSPIWrapper.cs

示例15: VerifySignature

 public static int VerifySignature(SSPIInterface secModule, SafeDeleteContext context, SecurityBuffer[] input, uint sequenceNumber)
 {
     return EncryptDecryptHelper(OP.VerifySignature, secModule, context, input, sequenceNumber);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:SSPIWrapper.cs


注:本文中的System.Net.Security.SSPIInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。