@@ -43,8 +43,6 @@ public class Identity {
4343
4444 private char [] pswd ;
4545
46- private Logger logger = null ;
47-
4846 /**
4947 * Creates an Identity instance.this type of the instance can
5048 * only be used to store server certificate identity.
@@ -56,18 +54,15 @@ public class Identity {
5654 public Identity (MerchantConfig merchantConfig ,X509Certificate x509Certificate ,Logger logger ) throws SignException {
5755 this .merchantConfig = merchantConfig ;
5856 this .x509Cert =x509Certificate ;
59- if (this .logger == null ){
60- this .logger =logger ;
61- }
6257 if (merchantConfig .isJdkCertEnabled () || merchantConfig .isCacertEnabled ()){
6358 setupJdkServerCerts ();
6459 }
6560 else {
6661 setUpServer ();
6762 }
6863 }
64+
6965 private void setupJdkServerCerts () throws SignException {
70-
7166 if (x509Cert != null ) {
7267 String subjectDN = x509Cert .getSubjectDN ().getName ();
7368 if (subjectDN != null ) {
@@ -82,7 +77,6 @@ else if (subjectDNrray.length == 2 && subjectDNrray[1].contains(SERVER_ALIAS)) {
8277 }else {
8378 throw new SignException ("Exception while obtaining private key from KeyStore with alias, '" + merchantConfig .getKeyAlias () + "'" );
8479 }
85-
8680 } else {
8781 throw new SignException ("Exception while obtaining private key from KeyStore with alias, '" + merchantConfig .getKeyAlias () + "'" );
8882 }
@@ -99,17 +93,13 @@ else if (subjectDNrray.length == 2 && subjectDNrray[1].contains(SERVER_ALIAS)) {
9993 * @param privateKey
10094 * @throws SignException
10195 */
102- public Identity (MerchantConfig merchantConfig ,X509Certificate x509Certificate , PrivateKey privateKey ,Logger logger ) throws SignException {
96+ public Identity (MerchantConfig merchantConfig ,X509Certificate x509Certificate , PrivateKey privateKey , Logger logger ) throws SignException {
10397 this .merchantConfig = merchantConfig ;
10498 this .x509Cert = x509Certificate ;
10599 this .privateKey = privateKey ;
106- if (this .logger == null ){
107- this .logger =logger ;
108- }
109100 try {
110101 this .lastModifiedDate =merchantConfig .getKeyFile ().lastModified ();
111102 } catch (ConfigException e ) {
112-
113103 logger .log (Logger .LT_EXCEPTION ,
114104 "Identity object ,cannot instantiate with key file lastModifiedDate. "
115105 + e .getMessage ());
@@ -123,7 +113,7 @@ public Identity(MerchantConfig merchantConfig,X509Certificate x509Certificate, P
123113 * else isValid method will return true and certificate reload will not occur.
124114 */
125115
126- public boolean isValid (File keyFile ) {
116+ public boolean isValid (File keyFile , Logger logger ) {
127117 boolean changeKeyFileStatus =(this .lastModifiedDate == keyFile .lastModified ());
128118 if (!changeKeyFileStatus ) {
129119 logger .log (Logger .LT_INFO , "Key file changed" );
@@ -136,14 +126,14 @@ private void setUpMerchant() throws SignException {
136126 if (serialNumber == null && x509Cert != null ) {
137127 String subjectDN = x509Cert .getSubjectDN ().getName ();
138128 if (subjectDN != null ) {
139- String subjectDNrray [] = subjectDN .split ("SERIALNUMBER=" );
129+ String [] subjectDNrray = subjectDN .split ("SERIALNUMBER=" );
140130 if (subjectDNrray .length != 2 ) {
141131 throw new SignException ("Exception while obtaining private key from KeyStore with alias, '" + merchantConfig .getKeyAlias () + "'" );
142132 }
143133 name = merchantConfig .getMerchantID ();
144134 pswd = merchantConfig .getKeyPassword ().toCharArray ();
145135 serialNumber = subjectDNrray [1 ];
146- keyAlias = "serialNumber=" + serialNumber + ",CN=" + name ;
136+ keyAlias = merchantConfig . getKeyAlias () ;
147137 } else {
148138 throw new SignException ("Exception while obtaining private key from KeyStore with alias, '" + merchantConfig .getKeyAlias () + "'" );
149139 }
@@ -155,7 +145,7 @@ private void setUpServer() throws SignException {
155145 if (serialNumber == null && x509Cert != null ) {
156146 String subjectDN = x509Cert .getSubjectDN ().getName ();
157147 if (subjectDN != null ) {
158- String subjectDNrray [] = subjectDN .split ("SERIALNUMBER=" );
148+ String [] subjectDNrray = subjectDN .split ("SERIALNUMBER=" );
159149 if (subjectDNrray .length == 1 && subjectDNrray [0 ].contains ("CyberSourceCertAuth" )){
160150 name = keyAlias = "CyberSourceCertAuth" ;
161151 }
0 commit comments