4
4
using System . ServiceModel ;
5
5
using System . Xml . Serialization ;
6
6
using System . ServiceModel . Channels ;
7
+ using System . ServiceModel . Security . Tokens ;
7
8
8
9
namespace CyberSource . Clients
9
10
{
@@ -15,7 +16,7 @@ public abstract class BaseClient
15
16
/// <summary>
16
17
/// Version of this client.
17
18
/// </summary>
18
- public const string CLIENT_LIBRARY_VERSION = "1.0.1 " ;
19
+ public const string CLIENT_LIBRARY_VERSION = "1.4.0 " ;
19
20
20
21
/// <summary>
21
22
/// Proxy object that is initialized during start-up, if needed.
@@ -40,6 +41,9 @@ public abstract class BaseClient
40
41
private const string PROXY_PASSWORD = "proxyPassword" ;
41
42
private const string BASIC_AUTH = "Basic" ;
42
43
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
+
43
47
static BaseClient ( )
44
48
{
45
49
SetupProxy ( ) ;
@@ -211,6 +215,12 @@ int boolVal
211
215
= AppSettings . GetIntSetting (
212
216
merchantID , Configuration . CONNECTION_LIMIT ) ;
213
217
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
+
214
224
return ( config ) ;
215
225
}
216
226
@@ -303,7 +313,7 @@ protected static void SetConnectionLimit(Configuration config)
303
313
/// Returns a custom wcf binding that will create a SOAP request
304
314
/// compatible with the Simple Order API Service
305
315
/// </summary>
306
- protected static CustomBinding getWCFCustomBinding ( )
316
+ protected static CustomBinding getWCFCustomBinding ( Configuration config )
307
317
{
308
318
//Setup custom binding with HTTPS + Body Signing
309
319
CustomBinding currentBinding = new CustomBinding ( ) ;
@@ -315,6 +325,15 @@ protected static CustomBinding getWCFCustomBinding()
315
325
asec . EnableUnsecuredResponse = true ;
316
326
asec . SecurityHeaderLayout = SecurityHeaderLayout . Lax ;
317
327
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
+
318
337
//Use custom encoder to strip unsigned timestamp in response
319
338
CustomTextMessageBindingElement textBindingElement = new CustomTextMessageBindingElement ( ) ;
320
339
0 commit comments