Author: tabish Date: Mon Jan 13 23:17:03 2014 New Revision: 1557883 URL: http://svn.apache.org/r1557883 Log: https://issues.apache.org/jira/browse/AMQNET-454
applied: https://issues.apache.org/jira/secure/attachment/12622717/Apache.NMS.AMQP-set-connection-credentials-08.patch Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/Connection.cs activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/ConnectionFactory.cs Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/Connection.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/Connection.cs?rev=1557883&r1=1557882&r2=1557883&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/Connection.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/Connection.cs Mon Jan 13 23:17:03 2014 @@ -36,6 +36,8 @@ namespace Apache.NMS.Amqp private const string PROTOCOL_1_0 = "amqp1.0"; private const char SEP_ARGS = ','; private const char SEP_NAME_VALUE = ':'; + public const string USERNAME_OPTION = "username"; + public const string PASSWORD_OPTION = "password"; private static readonly TimeSpan InfiniteTimeSpan = TimeSpan.FromMilliseconds(Timeout.Infinite); @@ -57,7 +59,7 @@ namespace Apache.NMS.Amqp private string clientId; private StringDictionary connectionProperties; - private int sessionCounter = 0; + private int sessionCounter = 0; private readonly IList sessions = ArrayList.Synchronized(new ArrayList()); private Org.Apache.Qpid.Messaging.Connection qpidConnection = null; // Don't create until Start() @@ -246,8 +248,8 @@ namespace Apache.NMS.Amqp public IRedeliveryPolicy RedeliveryPolicy { get { return this.redeliveryPolicy; } - set - { + set + { ThrowIfConnected("RedeliveryPolicy"); this.redeliveryPolicy = value; } @@ -257,10 +259,10 @@ namespace Apache.NMS.Amqp public ConsumerTransformerDelegate ConsumerTransformer { get { return this.consumerTransformer; } - set + set { ThrowIfConnected("ConsumerTransformer"); - this.consumerTransformer = value; + this.consumerTransformer = value; } } @@ -268,7 +270,7 @@ namespace Apache.NMS.Amqp public ProducerTransformerDelegate ProducerTransformer { get { return this.producerTransformer; } - set + set { ThrowIfConnected("ProducerTransformer"); this.producerTransformer = value; @@ -333,12 +335,12 @@ namespace Apache.NMS.Amqp // Allocate a Qpid connection if (qpidConnection == null) { - qpidConnection = + qpidConnection = new Org.Apache.Qpid.Messaging.Connection( - brokerUri.ToString(), + brokerUri.ToString(), ConstructConnectionOptionsString()); } - + // Open the connection if (!qpidConnection.IsOpen) { @@ -349,7 +351,7 @@ namespace Apache.NMS.Amqp } catch (Org.Apache.Qpid.Messaging.QpidException e) { - throw new ConnectionClosedException( e.Message ); + throw new ConnectionClosedException(e.Message); } } finally @@ -482,7 +484,7 @@ namespace Apache.NMS.Amqp public StringDictionary ConnectionProperties { get { return connectionProperties; } - set + set { ThrowIfConnected("ConnectionProperties"); connectionProperties = value; @@ -551,7 +553,7 @@ namespace Apache.NMS.Amqp public void HandleException(Exception e) { - if(ExceptionListener != null && !this.closed.Value) + if (ExceptionListener != null && !this.closed.Value) { ExceptionListener(e); } Modified: activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/ConnectionFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/ConnectionFactory.cs?rev=1557883&r1=1557882&r2=1557883&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/ConnectionFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.AMQP/trunk/src/main/csharp/ConnectionFactory.cs Mon Jan 13 23:17:03 2014 @@ -56,7 +56,7 @@ namespace Apache.NMS.Amqp public static string GetDefaultBrokerUrl() { string answer = Environment.GetEnvironmentVariable(ENV_BROKER_URL); - if(answer == null) + if (answer == null) { answer = DEFAULT_BROKER_URL; } @@ -144,6 +144,15 @@ namespace Apache.NMS.Amqp connection.ClientId = this.clientID; connection.ConnectionProperties = this.properties; + if (!String.IsNullOrEmpty(userName)) + { + connection.SetConnectionProperty(Connection.USERNAME_OPTION, userName); + } + if (!String.IsNullOrEmpty(password)) + { + connection.SetConnectionProperty(Connection.PASSWORD_OPTION, password); + } + IConnection ReturnValue = null; ReturnValue = connection; @@ -168,7 +177,7 @@ namespace Apache.NMS.Amqp get { return this.redeliveryPolicy; } set { - if(value != null) + if (value != null) { this.redeliveryPolicy = value; }
