44using System . ServiceModel ;
55using System . Xml . Serialization ;
66using System . ServiceModel . Channels ;
7+ using System . ServiceModel . Security . Tokens ;
78
89namespace CyberSource . Clients
910{
@@ -15,7 +16,7 @@ public abstract class BaseClient
1516 /// <summary>
1617 /// Version of this client.
1718 /// </summary>
18- public const string CLIENT_LIBRARY_VERSION = "1.0.1 " ;
19+ public const string CLIENT_LIBRARY_VERSION = "1.4.0 " ;
1920
2021 /// <summary>
2122 /// Proxy object that is initialized during start-up, if needed.
@@ -40,6 +41,9 @@ public abstract class BaseClient
4041 private const string PROXY_PASSWORD = "proxyPassword" ;
4142 private const string BASIC_AUTH = "Basic" ;
4243
44+ public const string CYBERSOURCE_PUBLIC_KEY = "CyberSource_SJC_US" ;
45+ public const string X509_CLAIMTYPE = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/x500distinguishedname" ;
46+
4347 static BaseClient ( )
4448 {
4549 SetupProxy ( ) ;
@@ -211,6 +215,12 @@ int boolVal
211215 = AppSettings . GetIntSetting (
212216 merchantID , Configuration . CONNECTION_LIMIT ) ;
213217
218+ // Encryption enable flag
219+ boolVal
220+ = AppSettings . GetBoolSetting (
221+ merchantID , Configuration . USE_SIGNED_AND_ENCRYPTED ) ;
222+ if ( boolVal != - 1 ) config . UseSignedAndEncrypted = ( boolVal == 1 ) ;
223+
214224 return ( config ) ;
215225 }
216226
@@ -303,7 +313,7 @@ protected static void SetConnectionLimit(Configuration config)
303313 /// Returns a custom wcf binding that will create a SOAP request
304314 /// compatible with the Simple Order API Service
305315 /// </summary>
306- protected static CustomBinding getWCFCustomBinding ( )
316+ protected static CustomBinding getWCFCustomBinding ( Configuration config )
307317 {
308318 //Setup custom binding with HTTPS + Body Signing
309319 CustomBinding currentBinding = new CustomBinding ( ) ;
@@ -315,6 +325,15 @@ protected static CustomBinding getWCFCustomBinding()
315325 asec . EnableUnsecuredResponse = true ;
316326 asec . SecurityHeaderLayout = SecurityHeaderLayout . Lax ;
317327
328+ if ( config . UseSignedAndEncrypted )
329+ {
330+ asec . LocalClientSettings . IdentityVerifier = new CustomeIdentityVerifier ( ) ;
331+ asec . RecipientTokenParameters = new System . ServiceModel . Security . Tokens . X509SecurityTokenParameters { InclusionMode = SecurityTokenInclusionMode . Once } ;
332+ asec . MessageProtectionOrder = System . ServiceModel . Security . MessageProtectionOrder . SignBeforeEncrypt ;
333+ asec . EndpointSupportingTokenParameters . SignedEncrypted . Add ( new System . ServiceModel . Security . Tokens . X509SecurityTokenParameters ( ) ) ;
334+ asec . SetKeyDerivation ( false ) ;
335+ }
336+
318337 //Use custom encoder to strip unsigned timestamp in response
319338 CustomTextMessageBindingElement textBindingElement = new CustomTextMessageBindingElement ( ) ;
320339
0 commit comments