99 */
1010package com .cybersource .ws .client ;
1111
12+ import java .io .File ;
1213import java .security .PrivateKey ;
1314import java .security .cert .CertificateEncodingException ;
1415import java .security .cert .X509Certificate ;
@@ -35,9 +36,15 @@ public class Identity {
3536 private PrivateKey privateKey ;
3637
3738 private MerchantConfig merchantConfig ;
39+
40+ private long lastModifiedDate ;
3841
3942 private static final String SERVER_ALIAS = "CyberSource_SJC_US" ;
4043
44+ Logger logger ;
45+
46+
47+
4148 /**
4249 * Creates an Identity instance.this type of the instance can
4350 * only be used to store server certificate identity.
@@ -93,9 +100,23 @@ public Identity(MerchantConfig merchantConfig,X509Certificate x509Certificate, P
93100 this .merchantConfig = merchantConfig ;
94101 this .x509Cert = x509Certificate ;
95102 this .privateKey = privateKey ;
103+ try {
104+ this .lastModifiedDate =merchantConfig .getKeyFile ().lastModified ();
105+ } catch (ConfigException e ) {
106+ logger .log (Logger .LT_EXCEPTION ,
107+ "Identity object ,cannot instantiate with key file lastModifiedDate. "
108+ + e .getMessage ());
109+ throw new SignException (e .getMessage ());
110+ }
96111 setUpMerchant ();
97112 }
98113
114+ public boolean isValid (File keyFile )
115+ {
116+
117+ return this .lastModifiedDate == keyFile .lastModified ();
118+ }
119+
99120 private void setUpMerchant () throws SignException {
100121 if (serialNumber == null && x509Cert != null ) {
101122 String subjectDN = x509Cert .getSubjectDN ().getName ();
0 commit comments