导出 (0) 打印
全部展开
展开 最小化

RelayClientAuthenticationType 枚举

注:本页面内容可能不完全适用中国大陆地区运营的 Windows Azure服务。如要了解不同地区 Windows Azure 服务的差异, 请参考本网站.

描述是否要求服务的客户端在发送消息时向 Windows Azure Service Bus 提供由 Windows Azure 访问控制颁发的安全令牌。

命名空间:  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 访问控制保护。
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();

社区附加资源

添加
显示:
© 2014 Microsoft