匯出 (0) 列印
全部展開
Expand Minimize
本主題尚未接受評分 - 為這個主題評分

RelayClientAuthenticationType 列舉

描述在傳送訊息時,服務的用戶端是否必須對 Windows Azure Service Bus 出具 Windows Azure Access Control 所簽發的安全性權杖。

命名空間:  Microsoft.ServiceBus
組件:  Microsoft.ServiceBus (在 Microsoft.ServiceBus.dll 中)
[DataContractAttribute(Name = "RelayClientAuthenticationType", Namespace = "http://schemas.microsoft.com/netservices/2009/05/servicebus/connect")]
public enum RelayClientAuthenticationType
成員名稱說明
None如果是由接聽程式所指定,用戶端將不需提供安全性權杖。這代表選擇不加入機制,接聽程式可以使用此機制來放棄端點上的 Windows Azure Access Control 保護。
RelayAccessToken如果是由接聽程式所指定,用戶端將需要提供安全性權杖。

Windows Azure Service Bus supports only Full Trust code access security.

The Windows Azure Service Bus bindings use a federated security token authorization scheme to guard access to the Windows Azure Service Bus and to the services listening through it.

This value controls whether clients of a service are required to present a security token issued by the Windows Azure Access Control service to the Windows Azure Service Bus service when sending messages. Services (listeners) are always required to authenticate with Windows Azure Access Control and present an authorization token to the Windows Azure Service Bus. However, the client is only required to authenticate with the Windows Azure Service Bus only if the RelayClientAuthenticationType is set to RelayAccessToken. Setting RelayClientAuthenticationType to None waives the requirement of a token. You may wish to opt out of authentication on the client (sender) in the Service Bus leg of the communication if you are providing your own authentication or if you do not need authentication.The default value is RelayClientAuthenticationType.RelayAccessToken.

For more information on setting security parameters when initializing an Windows Azure Service Bus application, see Securing and Authenticating an AppFabric Service Bus Connection and Configuring an AppFabric Service Bus Application.

The following example creates a channel factory and initializes it with a binding that is explicitly configured to use the RelayAccessToken authentication type. This is achieved by calling the parameterized NetTcpRelayBinding constructor NetTcpRelayBinding(EndToEndSecurityMode, RelayClientAuthenticationType) instead of the default constructor. However, note that in this case the default constructor yields the same result since it initializes the authentication type and transport to the same values as the ones explicitly specified in this example. This example is a modified version of the Client project in the Echo sample; it has the binding defined programmatically instead of having it specified in the App.config file.

Console.Write("Your Service Namespace (ex. sb://<ServiceNamespace>.servicebus.windows.net/): ");
string serviceNamespace = Console.ReadLine();
Console.Write("Your Issuer Name: ");
string issuerName = Console.ReadLine();
Console.Write("Your Issuer Secret: ");
string issuerSecret = Console.ReadLine();

// Create the service URI based on the service namespace.
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

// Create the credentials object for the endpoint.
TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = issuerName;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = issuerSecret;

// Create the channel factory.
ChannelFactory<IEchoChannel> channelFactory = 
    new ChannelFactory<IEchoChannel>(new NetTcpRelayBinding(EndToEndSecurityMode.Transport, RelayClientAuthenticationType.RelayAccessToken), new EndpointAddress(serviceUri));

// Apply the Service Bus credentials.
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);

// Create and open the client channel.
IEchoChannel channel = channelFactory.CreateChannel();
channel.Open();

Console.WriteLine("Enter text to echo (or [Enter] to exit):");
string input = Console.ReadLine();
while (input != String.Empty)
{
    try
    {
        Console.WriteLine("Server echoed: {0}", channel.Echo(input));
    }
    catch (Exception e)
    {
        Console.WriteLine("Error: " + e.Message);
    }
    input = Console.ReadLine();
}

channel.Close();
channelFactory.Close();

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

新增
顯示:
© 2014 Microsoft. 著作權所有,並保留一切權利。