summaryrefslogtreecommitdiff
path: root/qpid/wcf
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2010-04-27 21:52:06 +0000
committerStephen D. Huston <shuston@apache.org>2010-04-27 21:52:06 +0000
commit428f4fd280bc9794a1f09c2afc634ba4cf0bb670 (patch)
tree34bf04d4d1ac97587a0b0a1f08fe4d6b5d11d47f /qpid/wcf
parent61cd187331ac9491240689f6de1b46bfb661a48e (diff)
downloadqpid-python-428f4fd280bc9794a1f09c2afc634ba4cf0bb670.tar.gz
Applied patch from QPID-2501.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@938691 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/wcf')
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpBinaryBinding.cs10
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpBinding.cs17
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpBindingConfigurationElement.cs75
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpChannelHelpers.cs24
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpSecurityElement.cs126
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs11
-rw-r--r--qpid/wcf/src/Apache/Qpid/Channel/Channel.csproj1
7 files changed, 247 insertions, 17 deletions
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinaryBinding.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinaryBinding.cs
index e207f2fe45..d533fc212e 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinaryBinding.cs
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinaryBinding.cs
@@ -44,7 +44,15 @@ namespace Apache.Qpid.Channel
private void ApplyConfiguration(string configurationName)
{
- AmqpBinaryBindingCollectionElement section = (AmqpBinaryBindingCollectionElement)ConfigurationManager.GetSection(AmqpConstants.AmqpBinaryBindingSectionName);
+ BindingsSection wcfBindings = (BindingsSection)ConfigurationManager.GetSection("system.serviceModel/bindings");
+ // wcfBindings contains system defined bindings and bindingExtensions
+
+ AmqpBinaryBindingCollectionElement section = (AmqpBinaryBindingCollectionElement)wcfBindings["amqpBinaryBinding"];
+ if (section == null)
+ {
+ throw new ConfigurationErrorsException("Missing \"amqpBinaryBinding\" configuration section.");
+ }
+
AmqpBinaryBindingConfigurationElement element = section.Bindings[configurationName];
if (element == null)
{
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinding.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinding.cs
index cfb2e6095c..be54f06b2f 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinding.cs
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBinding.cs
@@ -36,7 +36,7 @@ namespace Apache.Qpid.Channel
protected AmqpSecurity security;
public AmqpBinding()
- : this (new BinaryMessageEncodingBindingElement())
+ : this(new BinaryMessageEncodingBindingElement())
{
}
@@ -89,6 +89,11 @@ namespace Apache.Qpid.Channel
}
}
+ internal bool SecurityEnabled
+ {
+ get { return (transport.ChannelProperties.AmqpSecurityMode != AmqpSecurityMode.None); }
+ }
+
public bool Shared
{
get { return transport.Shared; }
@@ -124,7 +129,15 @@ namespace Apache.Qpid.Channel
private void ApplyConfiguration(string configurationName)
{
- AmqpBindingCollectionElement section = (AmqpBindingCollectionElement)ConfigurationManager.GetSection(AmqpConstants.AmqpBindingSectionName);
+ BindingsSection wcfBindings = (BindingsSection)ConfigurationManager.GetSection("system.serviceModel/bindings");
+ // wcfBindings contains system defined bindings and bindingExtensions
+
+ AmqpBindingCollectionElement section = (AmqpBindingCollectionElement)wcfBindings["amqpBinding"];
+ if (section == null)
+ {
+ throw new ConfigurationErrorsException("Missing \"amqpBinding\" configuration section.");
+ }
+
AmqpBindingConfigurationElement element = section.Bindings[configurationName];
if (element == null)
{
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBindingConfigurationElement.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBindingConfigurationElement.cs
index 554824cea9..edc91e67c1 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/AmqpBindingConfigurationElement.cs
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpBindingConfigurationElement.cs
@@ -26,6 +26,7 @@ namespace Apache.Qpid.Channel
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
+ using System.Threading;
using Apache.Qpid.AmqpTypes;
public class AmqpBindingConfigurationElement : StandardBindingElement
@@ -97,6 +98,13 @@ namespace Apache.Qpid.Channel
}
}
+ [ConfigurationProperty(AmqpConfigurationStrings.Security)]
+ public AmqpSecurityElement Security
+ {
+ get { return (AmqpSecurityElement)base[AmqpConfigurationStrings.Security]; }
+ set { base[AmqpConfigurationStrings.Security] = value; }
+ }
+
protected override ConfigurationPropertyCollection Properties
{
get
@@ -109,6 +117,7 @@ namespace Apache.Qpid.Channel
properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.TransferMode,
typeof(TransferMode), AmqpDefaults.TransferMode, null, null, ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty("brokers", typeof(BrokerCollection), null));
+ properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.Security, typeof(AmqpSecurityElement), null));
return properties;
}
}
@@ -123,6 +132,40 @@ namespace Apache.Qpid.Channel
this.Shared = amqpBinding.Shared;
this.PrefetchLimit = amqpBinding.PrefetchLimit;
+ if (!amqpBinding.SecurityEnabled)
+ {
+ this.Security = null;
+ }
+ else
+ {
+ if (this.Security == null)
+ {
+ this.Security = new AmqpSecurityElement();
+ }
+
+ AmqpTransportSecurity sec = amqpBinding.Security.Transport;
+ this.Security.Mode = AmqpSecurityMode.Transport;
+ if (this.Security.Transport == null)
+ {
+ this.Security.Transport = new AmqpTransportSecurityElement();
+ }
+
+ this.Security.Transport.CredentialType = sec.CredentialType;
+ this.Security.Transport.IgnoreEndpointCredentials = sec.IgnoreEndpointClientCredentials;
+ this.Security.Transport.UseSSL = sec.UseSSL;
+ if (sec.DefaultCredential == null)
+ {
+
+ this.Security.Transport.DefaultCredential = null;
+ }
+ else
+ {
+ this.Security.Transport.DefaultCredential = new AmqpCredentialElement();
+ this.Security.Transport.DefaultCredential.UserName = sec.DefaultCredential.UserName;
+ this.Security.Transport.DefaultCredential.Password = sec.DefaultCredential.Password;
+ }
+ }
+
AmqpProperties props = amqpBinding.DefaultMessageProperties;
}
@@ -144,7 +187,39 @@ namespace Apache.Qpid.Channel
amqpBinding.TransferMode = this.TransferMode;
amqpBinding.Shared = this.Shared;
amqpBinding.PrefetchLimit = this.PrefetchLimit;
+
+ AmqpSecurityMode mode = AmqpSecurityMode.None;
+ if (this.Security != null)
+ {
+ mode = this.Security.Mode;
+ }
+
+ if (mode == AmqpSecurityMode.None)
+ {
+ if (amqpBinding.SecurityEnabled)
+ {
+ amqpBinding.Security.Mode = AmqpSecurityMode.None;
+ }
+ }
+ else
+ {
+ amqpBinding.Security.Mode = AmqpSecurityMode.Transport;
+ amqpBinding.Security.Transport.CredentialType = this.Security.Transport.CredentialType;
+ amqpBinding.Security.Transport.IgnoreEndpointClientCredentials = this.Security.Transport.IgnoreEndpointCredentials;
+ amqpBinding.Security.Transport.UseSSL = this.Security.Transport.UseSSL;
+ if (this.Security.Transport.DefaultCredential != null)
+ {
+ amqpBinding.Security.Transport.DefaultCredential = new AmqpCredential(
+ this.Security.Transport.DefaultCredential.UserName,
+ this.Security.Transport.DefaultCredential.Password);
+ }
+ else
+ {
+ amqpBinding.Security.Transport.DefaultCredential = null;
+ }
+ }
}
+
protected override void PostDeserialize()
{
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpChannelHelpers.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpChannelHelpers.cs
index 2a5b9410dc..b431689c4d 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/AmqpChannelHelpers.cs
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpChannelHelpers.cs
@@ -50,6 +50,15 @@ namespace Apache.Qpid.Channel
public const string PrefetchLimit = "prefetchLimit";
public const string MaxBufferPoolSize = "maxBufferPoolSize";
public const string MaxReceivedMessageSize = "maxReceivedMessageSize";
+ public const string Security = "security";
+ public const string SecurityMode = "mode";
+ public const string SecurityTransport = "transport";
+ public const string SecurityTransportCredentialType = "credentialType";
+ public const string SecurityTransportUseSSL = "useSSL";
+ public const string SecurityTransportDefaultCredential = "defaultCredential";
+ public const string SecurityTransportIgnoreEndpointCredentials = "ignoreEndpointCredentials";
+ public const string CredentialUserName = "userName";
+ public const string CredentialPassword = "password";
}
static class AmqpDefaults
@@ -195,7 +204,7 @@ namespace Apache.Qpid.Channel
AmqpCredential amqpCred = bindingContext.BindingParameters.Find<AmqpCredential>();
if (amqpCred != null)
{
- channelProperties.AmqpCredential = amqpCred;
+ channelProperties.AmqpCredential = amqpCred.Clone();
return;
}
@@ -204,9 +213,15 @@ namespace Apache.Qpid.Channel
ClientCredentials cliCred = bindingContext.BindingParameters.Find<ClientCredentials>();
if (cliCred != null)
{
- channelProperties.AmqpCredential = new AmqpCredential(cliCred.UserName.UserName,
- cliCred.UserName.Password);
- return;
+ if (cliCred.UserName != null)
+ {
+ if (cliCred.UserName.UserName != null)
+ {
+ channelProperties.AmqpCredential = new AmqpCredential(cliCred.UserName.UserName,
+ cliCred.UserName.Password);
+ return;
+ }
+ }
}
}
@@ -215,6 +230,5 @@ namespace Apache.Qpid.Channel
channelProperties.AmqpCredential = tsec.DefaultCredential.Clone();
}
}
-
}
}
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpSecurityElement.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpSecurityElement.cs
new file mode 100644
index 0000000000..f7370e40f5
--- /dev/null
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpSecurityElement.cs
@@ -0,0 +1,126 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+namespace Apache.Qpid.Channel
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.Configuration;
+ using System.ServiceModel;
+ using System.ServiceModel.Channels;
+ using System.ServiceModel.Configuration;
+ using Apache.Qpid.AmqpTypes;
+
+ public sealed class AmqpSecurityElement : ConfigurationElement
+ {
+ public AmqpSecurityElement()
+ {
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityMode,
+ typeof(AmqpSecurityMode), AmqpSecurityMode.None, null, null, ConfigurationPropertyOptions.None));
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityTransport,
+ typeof(AmqpTransportSecurityElement), null));
+
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityMode, DefaultValue = AmqpSecurityMode.None)]
+ public AmqpSecurityMode Mode
+ {
+ get { return (AmqpSecurityMode)base[AmqpConfigurationStrings.SecurityMode]; }
+ set { base[AmqpConfigurationStrings.SecurityMode] = value; }
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityTransport)]
+ public AmqpTransportSecurityElement Transport
+ {
+ get { return (AmqpTransportSecurityElement)base[AmqpConfigurationStrings.SecurityTransport]; }
+ set { base[AmqpConfigurationStrings.SecurityTransport] = value; }
+ }
+ }
+
+ public class AmqpTransportSecurityElement : ConfigurationElement
+ {
+ public AmqpTransportSecurityElement()
+ {
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportCredentialType,
+ typeof(AmqpCredentialType), AmqpCredentialType.Anonymous, null, null, ConfigurationPropertyOptions.None));
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportUseSSL,
+ typeof(bool), false, null, null, ConfigurationPropertyOptions.None));
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportDefaultCredential,
+ typeof(AmqpCredentialElement), null));
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportIgnoreEndpointCredentials,
+ typeof(bool), false, null, null, ConfigurationPropertyOptions.None));
+
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportCredentialType, DefaultValue = AmqpCredentialType.Anonymous)]
+ public AmqpCredentialType CredentialType
+ {
+ get { return (AmqpCredentialType)base[AmqpConfigurationStrings.SecurityTransportCredentialType]; }
+ set { base[AmqpConfigurationStrings.SecurityTransportCredentialType] = value; }
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportUseSSL, DefaultValue = false)]
+ public bool UseSSL
+ {
+ get { return (bool)base[AmqpConfigurationStrings.SecurityTransportUseSSL]; }
+ set { base[AmqpConfigurationStrings.SecurityTransportUseSSL] = value; }
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportDefaultCredential, DefaultValue = null)]
+ public AmqpCredentialElement DefaultCredential
+ {
+ get { return (AmqpCredentialElement)base[AmqpConfigurationStrings.SecurityTransportDefaultCredential]; }
+ set { base[AmqpConfigurationStrings.SecurityTransportDefaultCredential] = value; }
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.SecurityTransportIgnoreEndpointCredentials, DefaultValue = false)]
+ public bool IgnoreEndpointCredentials
+ {
+ get { return (bool)base[AmqpConfigurationStrings.SecurityTransportIgnoreEndpointCredentials]; }
+ set { base[AmqpConfigurationStrings.SecurityTransportIgnoreEndpointCredentials] = value; }
+ }
+ }
+
+ public class AmqpCredentialElement : ConfigurationElement
+ {
+ public AmqpCredentialElement()
+ {
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.CredentialUserName,
+ typeof(string), "", null, null, ConfigurationPropertyOptions.None));
+ Properties.Add(new ConfigurationProperty(AmqpConfigurationStrings.CredentialPassword,
+ typeof(string), "", null, null, ConfigurationPropertyOptions.None));
+
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.CredentialUserName, DefaultValue = "")]
+ public string UserName
+ {
+ get { return (string)base[AmqpConfigurationStrings.CredentialUserName]; }
+ set { base[AmqpConfigurationStrings.CredentialUserName] = value; }
+ }
+
+ [ConfigurationProperty(AmqpConfigurationStrings.CredentialPassword, DefaultValue = "")]
+ public string Password
+ {
+ get { return (string)base[AmqpConfigurationStrings.CredentialPassword]; }
+ set { base[AmqpConfigurationStrings.CredentialPassword] = value; }
+ }
+ }
+}
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs b/qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs
index 41c36c7bcd..b722983ead 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs
+++ b/qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs
@@ -73,15 +73,8 @@ namespace Apache.Qpid.Channel
/// </summary>
public AmqpCredential DefaultCredential
{
- get
- {
- if (this.defaultCredential == null)
- {
- this.defaultCredential = new AmqpCredential("", "");
- }
-
- return this.defaultCredential;
- }
+ get { return this.defaultCredential; }
+ set { this.defaultCredential = value; }
}
/// <summary>
diff --git a/qpid/wcf/src/Apache/Qpid/Channel/Channel.csproj b/qpid/wcf/src/Apache/Qpid/Channel/Channel.csproj
index dfa41c9417..6bb059daf6 100644
--- a/qpid/wcf/src/Apache/Qpid/Channel/Channel.csproj
+++ b/qpid/wcf/src/Apache/Qpid/Channel/Channel.csproj
@@ -67,6 +67,7 @@ under the License.
<Compile Include="AmqpCredential.cs" />
<Compile Include="AmqpCredentialType.cs" />
<Compile Include="AmqpSecurity.cs" />
+ <Compile Include="AmqpSecurityElement.cs" />
<Compile Include="AmqpSecurityMode.cs" />
<Compile Include="AmqpChannelFactory.cs" />
<Compile Include="AmqpChannelHelpers.cs" />