日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[WCF安全系列]绑定、安全模式与客户端凭证类型:NetNamedPipeBinding、NetTcpBinding与NetMsmqBinding...

發布時間:2023/11/29 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [WCF安全系列]绑定、安全模式与客户端凭证类型:NetNamedPipeBinding、NetTcpBinding与NetMsmqBinding... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在前面兩篇(《綁定、安全模式與客戶端憑證類型:BasicHttpBinding》和《綁定、安全模式與客戶端憑證類型:WSHttpBinding與WSDualHttpBinding》)中,我們詳細地介紹了四種基于HTTP的綁定分別支持的安全模式,已經在相應的安全模式下可以采用怎樣的客戶端憑證。在本篇文章中,我們安全線相同的方式來介紹三種基于局域網的綁定,即NetNamedPipeBinding、NetTcpBinding與 NetMsmqBinding。

一、NetNamedPipeBinding

NetNamedPipeBinding只能用于同一臺機器上的不同進程之間的通信(IPC:Inter-Process Communication)。在IPC這樣的通信場景下,根本不需要基于Message模式的安全。所以在表示NetNamedPipeBinding安全的NetNamedPipeSecurity類型中,表示支持的安全模式的Mode屬性對應的NetNamedPipeSecurityMode枚舉僅僅具有兩個選項:None和Transport。在默認的情況下,NetNamedPipeBinding采用Transport安全模式。

此外還有一點值得一提:表示Transport模式安全的NamedPipeTransportSecurity類并不存在ClientCredentialType屬性,因為它總是采用Windows作為其客戶端憑證。NetNamedPipeBinding安全相關的應用編程接口如下面的代碼片斷所示。

1: public class NetNamedPipeBinding : Binding, IBindingRuntimePreferences 2: { 3: //其他成員 4: public NetNamedPipeSecurity Security { get; set; } 5: } 6: public sealed class NetNamedPipeSecurity 7: { 8: //其他成員 9: public NetNamedPipeSecurityMode Mode { get; set; } 10: public NamedPipeTransportSecurity Transport { get; set; } 11: } 12: public enum NetNamedPipeSecurityMode 13: { 14: None, 15: Transport 16: } 17: public sealed class NamedPipeTransportSecurity 18: { 19: //不存在ClientCredentialType屬性 20: }

二、NetTcpBinding

較之NetNamedPipeBinding,NetTcpBinding涉及安全相關的定義就要復雜一些。Security屬性返回的是一個用于設置NetTcpBinding安全的NetTcpSecurity對象。表示安全模式的NetTcpSecurity的Mode屬性返回的是我們提到過的SecurityMode枚舉,意味著NetTcpSecurity和WSHttpBinding以及WS2007HttpBinding支持相同的安全模式集,即None、Transport、Message和Mixed(TransportWithMessageCredential)。在默認的情況下,NetTcpBinding采用Transport安全模式

NetTcpSecurity的Transport屬性返回的是一個用于進行Transport安全設置的TcpTransportSecurity類型對象。TcpTransportSecurity的ClientCredentialType屬性以TcpClientCredentialType枚舉的形式表示采用的客戶端憑證類型。定義在TcpClientCredentialType中的三個枚舉值表示NetTcpBinding在Transport模式下支持的所有客戶端憑證類型:None、Windows和Certificate。在默認的情況下,NetTcpBinding采用Windows憑證

而通過Message屬性返回的用于進行Message安全設置的則是一個MessageSecurityOverTcp類型對象。MessageSecurityOverTcp用于表示客戶端憑證類型的ClientCredentialType屬性的依然是MessageCredentialType,意味著NetTcpBinding和上述的三個WS綁定在Message模式下,具有相同的客戶端憑證集。在默認的情況下,NetTcpBinding采用Windows憑證。NetTcpBinding安全相關的應用編程接口如下面的代碼片斷所示。

1: public class NetTcpBinding : Binding, IBindingRuntimePreferences 2: { 3: //其他成員 4: public NetTcpSecurity Security { get;set} 5: } 6: public sealed class NetTcpSecurity 7: { 8: //其他成員 9: public SecurityMode Mode { get; set; } 10: public TcpTransportSecurity Transport { get; set; } 11: public MessageSecurityOverTcp Message { get; set; } 12: } 13: public sealed class TcpTransportSecurity 14: { 15: //其他成員 16: public TcpClientCredentialType ClientCredentialType { get; set; } 17: } 18: public sealed class MessageSecurityOverTcp 19: { 20: //其他成員 21: public MessageCredentialType ClientCredentialType { get; set; } 22: } 23: public enum TcpClientCredentialType 24: { 25: None, 26: Windows, 27: Certificate 28: }

三、NetMsmqBinding

NetMsmqBinding的Security屬性的類型為NetMsmqSecurity。而表示NetMsmqBinding采用的安全模式的Mode屬性返回一個NetMsmqSecurityMode枚舉。NetMsmqSecurityMode枚舉的定義反映了NetMsmqBinding支持的安全模式集與其它系統定義綁定都不太一樣。定義在NetMsmqSecurityMode的四個枚舉值反映了NetMsmqBinding支持的四種安全模式:None、Transport、Message和Both。

首先,NetMsmqBinding具有 一種獨有的安全模式Both。這種模式意味中同時采用Transport和Message,就像是加上了雙保險。有人可能會提出這樣的問題:如果同時采用Transport和Message兩種模式,性能豈不是會變得很差?但是,由于MSMQ總是采用一種單向(One-Way)或者異步的消息發送機制,對性能并沒有太高的要求。此外,NetMsmqBinding并不支持Mixed(TransportWithMessageCredential)。在默認的情況下,NetMsmqBinding采用Transport安全模式

通過NetMsmqSecurity的Transport屬性返回的用于進行Transport安全設置的是一個類型為MsmqTransportSecurity的對象。和NetNamedPipeBinding類似,MsmqTransportSecurity并沒有一個ClientCredentialType屬性。這是因為在Transport模式下,NetMsmqBinding總是采用Windows憑證。而通過用于進行Message安全設置的Message屬性對應的類型為MessageSecurityOverMsmq。MessageSecurityOverMsmq具有一個類型為MessageCredentialType的ClientCredentialType屬性。NetMsmqSecurity安全相關的應用編程接口定義反映在下面的代碼片斷中。

1: public class NetMsmqBinding : MsmqBindingBase 2: { 3: //其他成員 4: public NetMsmqSecurity Security {get; set; } 5: } 6: public sealed class NetMsmqSecurity 7: { 8: //其他成員 9: public NetMsmqSecurityMode Mode { get; set; } 10: public MsmqTransportSecurity Transport { get; set; } 11: public MessageSecurityOverMsmq Message { get; set; } 12: } 13: public enum NetMsmqSecurityMode 14: { 15: None, 16: Transport, 17: Message, 18: Both 19: } 20: public sealed class MsmqTransportSecurity 21: { 22: //不存在ClientCredentialType屬性 23: } 24: 25: public sealed class MessageSecurityOverMsmq 26: { 27: //其他成員 28: public MessageCredentialType ClientCredentialType {get; set; } 29: }

總結

以上是生活随笔為你收集整理的[WCF安全系列]绑定、安全模式与客户端凭证类型:NetNamedPipeBinding、NetTcpBinding与NetMsmqBinding...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。