diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnectionFactory.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnectionFactory.cs
index 1727c13c..9a21d5d2 100644
--- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnectionFactory.cs
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnectionFactory.cs
@@ -18,15 +18,24 @@
#endregion
+using System;
using System.IO;
using System.Runtime.Serialization;
+using Spring.Objects.Factory;
using TIBCO.EMS;
namespace Spring.Messaging.Ems.Common
{
- public class EmsConnectionFactory : IConnectionFactory
+ public class EmsConnectionFactory : IConnectionFactory, IInitializingObject
{
private ConnectionFactory nativeConnectionFactory;
+ private string sslProxyAuthUsername;
+ private string sslProxyAuthPassword;
+
+ private string sslProxyHost;
+ private int sslProxyPort;
+
+
public EmsConnectionFactory(ConnectionFactory nativeConnectionFactory)
{
@@ -78,7 +87,8 @@ namespace Spring.Messaging.Ems.Common
public string SSLProxyHost
{
- get { return nativeConnectionFactory.GetSSLProxyHost(); }
+ get { return this.sslProxyHost; }
+ set { this.sslProxyHost = value; }
}
public string SSLProxyPassword
@@ -88,7 +98,8 @@ namespace Spring.Messaging.Ems.Common
public int SSLProxyPort
{
- get { return nativeConnectionFactory.GetSSLProxyPort(); }
+ get { return this.sslProxyPort; }
+ set { this.sslProxyPort = value; }
}
public string SSLProxyUser
@@ -96,9 +107,23 @@ namespace Spring.Messaging.Ems.Common
get { return nativeConnectionFactory.GetSSLProxyUser(); }
}
- public void SetCertificateStoreType(EMSSSLStoreType type, object storeInfo)
+ public IEmsSSLStoreType CertificateStoreType
{
- nativeConnectionFactory.SetCertificateStoreType(type, storeInfo);
+ set
+ {
+ if (value is EmsSSLFileStoreInfo)
+ {
+ EmsSSLFileStoreInfo emsSslFileStoreInfo = (EmsSSLFileStoreInfo) value;
+ nativeConnectionFactory.SetCertificateStoreType(EMSSSLStoreType.EMSSSL_STORE_TYPE_FILE, emsSslFileStoreInfo.NativeEmsSslFileStoreInfo);
+ } else if (value is EmsSSLSystemStoreInfo)
+ {
+ EmsSSLSystemStoreInfo info = (EmsSSLSystemStoreInfo) value;
+ nativeConnectionFactory.SetCertificateStoreType(EMSSSLStoreType.EMSSSL_STORE_TYPE_SYSTEM, info.NativeEmssslSystemStoreInfo);
+ } else
+ {
+ throw new ArgumentException("IEmsSSLStoreType of type [" + value.GetType() + "], not supported.");
+ }
+ }
}
public string ClientID
@@ -176,9 +201,16 @@ namespace Spring.Messaging.Ems.Common
nativeConnectionFactory.SetSSLProxy(host, port);
}
- public string[] SSLProxyAuth
+ public string SSLProxyAuthUsername
{
- set { nativeConnectionFactory.SetSSLProxyAuth(value[0], value[1]); }
+ set { this.sslProxyAuthUsername = value; }
+ get { return this.sslProxyAuthUsername; }
+ }
+
+ public string SSLProxyAuthPassword
+ {
+ set { this.sslProxyAuthPassword = value; }
+ get { return this.sslProxyAuthPassword; }
}
public bool SSLTrace
@@ -213,5 +245,15 @@ namespace Spring.Messaging.Ems.Common
}
#endregion
+
+ #region Implementation of IInitializingObject
+
+ public void AfterPropertiesSet()
+ {
+ nativeConnectionFactory.SetSSLProxyAuth(this.sslProxyAuthUsername, this.sslProxyAuthPassword);
+ nativeConnectionFactory.SetSSLProxy(this.sslProxyHost, this.sslProxyPort);
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLFileStoreInfo.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLFileStoreInfo.cs
new file mode 100644
index 00000000..e5739cba
--- /dev/null
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLFileStoreInfo.cs
@@ -0,0 +1,62 @@
+#region License
+
+/*
+ * Copyright © 2002-2009 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+#endregion
+
+using System.Security.Cryptography.X509Certificates;
+using TIBCO.EMS;
+
+namespace Spring.Messaging.Ems.Common
+{
+ public class EmsSSLFileStoreInfo : IEmsSSLStoreType
+ {
+ private EMSSSLFileStoreInfo nativeEmsSSLFileStoreInfo;
+
+ public virtual EMSSSLFileStoreInfo NativeEmsSslFileStoreInfo
+ {
+ get { return nativeEmsSSLFileStoreInfo; }
+ set { nativeEmsSSLFileStoreInfo = value; }
+ }
+
+ public X509Certificate SslClientIdentity
+ {
+ set { NativeEmsSslFileStoreInfo.SetSSLClientIdentity(value); }
+ }
+
+ public string SslClientIdentityAsString
+ {
+ set { NativeEmsSslFileStoreInfo.SetSSLClientIdentity(value); }
+ }
+
+ public string SslPassword
+ {
+ set { NativeEmsSslFileStoreInfo.SetSSLPassword(value.ToCharArray()); }
+ }
+
+ public X509Certificate SslTrustedCertificate
+ {
+ set { NativeEmsSslFileStoreInfo.SetSSLTrustedCertificate(value); }
+ }
+
+ public string SslTrustedCertificateAsString
+ {
+ set { NativeEmsSslFileStoreInfo.SetSSLTrustedCertificate(value); }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLSystemStoreInfo.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLSystemStoreInfo.cs
new file mode 100644
index 00000000..928589c9
--- /dev/null
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsSSLSystemStoreInfo.cs
@@ -0,0 +1,58 @@
+#region License
+
+/*
+ * Copyright © 2002-2009 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+#endregion
+
+using System.Security.Cryptography.X509Certificates;
+using TIBCO.EMS;
+
+namespace Spring.Messaging.Ems.Common
+{
+ public class EmsSSLSystemStoreInfo : IEmsSSLStoreType
+ {
+
+ private EMSSSLSystemStoreInfo emssslSystemStoreInfo;
+
+ public EMSSSLSystemStoreInfo NativeEmssslSystemStoreInfo
+ {
+ get { return emssslSystemStoreInfo; }
+ set { emssslSystemStoreInfo = value; }
+ }
+
+ public virtual EMSSSLSystemStoreInfo EmssslSystemStoreInfo
+ {
+ get { return emssslSystemStoreInfo; }
+ set { emssslSystemStoreInfo = value; }
+ }
+
+ public string CertificateNameAsFullSubjectDn
+ {
+ set { EmssslSystemStoreInfo.SetCertificateNameAsFullSubjectDN(value); }
+ }
+
+ public StoreLocation CertificateStoreLocation {
+
+ set { EmssslSystemStoreInfo.SetCertificateStoreLocation(value); }
+ }
+
+ public string CertificateStoreName
+ {
+ set { EmssslSystemStoreInfo.SetCertificateStoreName(value); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IConnectionFactory.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IConnectionFactory.cs
index f0c52c2d..4d7c638d 100644
--- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IConnectionFactory.cs
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IConnectionFactory.cs
@@ -32,13 +32,12 @@ namespace Spring.Messaging.Ems.Common
IConnection CreateConnection();
IConnection CreateConnection(string userName, string password);
object CertificateStore { get; }
- string SSLProxyHost { get; }
+ string SSLProxyHost { set; get; }
+ int SSLProxyPort { set; get; }
string SSLProxyPassword { get; }
- int SSLProxyPort { get; }
string SSLProxyUser { get; }
- void SetCertificateStoreType(EMSSSLStoreType type, object storeInfo);
-
+ IEmsSSLStoreType CertificateStoreType { set; }
string ClientID { set; }
StreamWriter ClientTracer { set; }
int ConnAttemptCount { set; }
@@ -56,10 +55,10 @@ namespace Spring.Messaging.Ems.Common
int ReconnAttemptTimeout { set; }
string ServerUrl { set; }
bool SSLAuthOnly { set; }
-
- void SetSSLProxy(string host, int port);
- string[] SSLProxyAuth { set; }
+
+ string SSLProxyAuthUsername { set; get; }
+ string SSLProxyAuthPassword { set; get; }
bool SSLTrace { set; }
string TargetHostName { set; }
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IEmsSSLStoreType.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IEmsSSLStoreType.cs
new file mode 100644
index 00000000..3dbc3179
--- /dev/null
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/IEmsSSLStoreType.cs
@@ -0,0 +1,30 @@
+#region License
+
+/*
+ * Copyright © 2002-2009 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+#endregion
+
+namespace Spring.Messaging.Ems.Common
+{
+ ///
+ /// Market interface for EMS SSL store types
+ ///
+ public interface IEmsSSLStoreType
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs
index d33c625d..d15b080b 100644
--- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs
@@ -98,7 +98,6 @@ namespace Spring.Messaging.Ems.Connections
///
private object connectionMonitor = new object();
-
#endregion
#region Constructors
@@ -259,29 +258,20 @@ namespace Spring.Messaging.Ems.Connections
get { return TargetConnectionFactory.CertificateStore; }
}
- public string SSLProxyHost
- {
- get { return TargetConnectionFactory.SSLProxyHost; }
- }
public string SSLProxyPassword
{
get { return TargetConnectionFactory.SSLProxyPassword; }
}
- public int SSLProxyPort
- {
- get { return TargetConnectionFactory.SSLProxyPort; }
- }
-
public string SSLProxyUser
{
get { return TargetConnectionFactory.SSLProxyUser; }
}
- public void SetCertificateStoreType(EMSSSLStoreType type, object storeInfo)
+ public IEmsSSLStoreType CertificateStoreType
{
- TargetConnectionFactory.SetCertificateStoreType(type, storeInfo);
+ set { TargetConnectionFactory.CertificateStoreType = value; }
}
public string ClientID
@@ -358,14 +348,28 @@ namespace Spring.Messaging.Ems.Connections
set { TargetConnectionFactory.SSLAuthOnly = value; }
}
- public void SetSSLProxy(string host, int port)
+ public string SSLProxyHost
{
- TargetConnectionFactory.SetSSLProxy(host, port);
+ get { return TargetConnectionFactory.SSLProxyHost; }
+ set { TargetConnectionFactory.SSLProxyHost = value; }
+ }
+
+ public int SSLProxyPort
+ {
+ get { return TargetConnectionFactory.SSLProxyPort;}
+ set { TargetConnectionFactory.SSLProxyPort = value; }
}
- public string[] SSLProxyAuth
+ public string SSLProxyAuthUsername
{
- set { TargetConnectionFactory.SSLProxyAuth = value; }
+ set { TargetConnectionFactory.SSLProxyAuthUsername = value; }
+ get { return TargetConnectionFactory.SSLProxyAuthUsername; }
+ }
+
+ public string SSLProxyAuthPassword
+ {
+ set { TargetConnectionFactory.SSLProxyAuthPassword = value; }
+ get { return TargetConnectionFactory.SSLProxyAuthPassword; }
}
public bool SSLTrace
@@ -396,6 +400,8 @@ namespace Spring.Messaging.Ems.Connections
#endregion
+
+
#region Implementation of ISerializable
public void GetObjectData(SerializationInfo info, StreamingContext context)
@@ -537,6 +543,10 @@ namespace Spring.Messaging.Ems.Connections
{
throw new ArgumentException("Connection or 'TargetConnectionFactory' is required.");
}
+ // Note this is repeated in EmsConnectionFactory as this class only referes to IConnectionFactory and
+ // IConnectionFactory does not implement the spring specific lifecycle interface IInitializingObject
+ TargetConnectionFactory.NativeConnectionFactory.SetSSLProxyAuth(SSLProxyAuthUsername, SSLProxyAuthPassword);
+ TargetConnectionFactory.NativeConnectionFactory.SetSSLProxy(SSLProxyHost, SSLProxyPort);
}
#endregion
diff --git a/src/Spring/Spring.Messaging.Ems/Spring.Messaging.Ems.2008.csproj b/src/Spring/Spring.Messaging.Ems/Spring.Messaging.Ems.2008.csproj
index 2ea80f83..91463f2b 100644
--- a/src/Spring/Spring.Messaging.Ems/Spring.Messaging.Ems.2008.csproj
+++ b/src/Spring/Spring.Messaging.Ems/Spring.Messaging.Ems.2008.csproj
@@ -76,12 +76,15 @@
+
+
+