SALES: 1-800-867-1380
Expand Minimize

RelayClientAuthenticationType Enumeration

Describes whether clients of a service are required to present a security token issued by Windows Azure Access Control to the Windows Azure Service Bus when sending messages.

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

[DataContractAttribute(Name = "RelayClientAuthenticationType", Namespace = "")]
public enum RelayClientAuthenticationType

Member nameDescription
NoneIf specified by a listener, the client will not be required to provide a security token. This represents an opt-out mechanism with which listeners can waive the Windows Azure Access Control protection on the endpoint.
RelayAccessTokenIf specified by a listener, the client is required to provide a security token.

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> ");
string serviceNamespace = Console.ReadLine();
Console.Write("Your SAS Policy Name: ");
string policyName = Console.ReadLine();
Console.Write("Your SAS Key: ");
string sasKey = 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 sasCredential = new TransportClientEndpointBehavior();
sasCredential.TokenProvider = 
  TokenProvider.CreateSharedAccessSignatureTokenProvider(policyName, sasKey);

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

// Apply the Service Bus credentials.

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

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft