|
26 | 26 | public class PayConfig implements Config {
|
27 | 27 |
|
28 | 28 | private String accessKey;
|
29 |
| - private String secretKey; |
| 29 | + private char[] secretKey; |
30 | 30 | private String merchantId;
|
31 | 31 | private Region region;
|
32 | 32 | private Environment environment;
|
@@ -143,27 +143,46 @@ public PayConfig withAccessKey(String accessKey) {
|
143 | 143 | *
|
144 | 144 | */
|
145 | 145 | @Override
|
146 |
| - public String getSecretKey() { |
| 146 | + public char[] getSecretKey() { |
147 | 147 | return secretKey;
|
148 | 148 | }
|
149 | 149 |
|
150 | 150 |
|
151 | 151 | /**
|
152 |
| - * |
| 152 | + * @deprecated(since = "3.7.0") This method is deprecated, instead use setSecretKey(char[] secretKey) |
153 | 153 | * @param secretKey - Sets SecretKey in PayConfig
|
154 | 154 | */
|
155 | 155 | @Override
|
| 156 | + @Deprecated |
156 | 157 | public void setSecretKey(String secretKey) {
|
157 |
| - this.secretKey = secretKey; |
| 158 | + this.secretKey = secretKey.toCharArray(); |
158 | 159 | }
|
| 160 | + |
| 161 | + /** |
| 162 | + * @param secretKey - Sets SecretKey in PayConfig |
| 163 | + */ |
| 164 | + @Override |
| 165 | + public void setSecretKey(char[] secretKey) { |
| 166 | + this.secretKey = secretKey; |
| 167 | + } |
159 | 168 |
|
160 | 169 |
|
161 | 170 | /**
|
162 |
| - * |
| 171 | + * @deprecated(since = "3.7.0") This method is deprecated, instead use withSecretKey(char[] privateKey) |
163 | 172 | * @param secretKey - Sets SecretKey in PayConfig
|
164 | 173 | * @return Returns updated PayConfig object
|
165 | 174 | */
|
| 175 | + @Deprecated |
166 | 176 | public PayConfig withSecretKey(String secretKey) {
|
| 177 | + this.secretKey = secretKey.toCharArray(); |
| 178 | + return this; |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * @param secretKey - Sets SecretKey in PayConfig |
| 183 | + * @return Returns updated PayConfig object |
| 184 | + */ |
| 185 | + public PayConfig withSecretKey(char[] secretKey) { |
167 | 186 | this.secretKey = secretKey;
|
168 | 187 | return this;
|
169 | 188 | }
|
@@ -605,7 +624,7 @@ private PayConfig loadConfigurationFromProperties(Properties prop) {
|
605 | 624 | this.setAccessKey(prop.getProperty(property));
|
606 | 625 | break;
|
607 | 626 | case SECRET_KEY:
|
608 |
| - this.setSecretKey(prop.getProperty(property)); |
| 627 | + this.setSecretKey(prop.getProperty(property).toCharArray()); |
609 | 628 | break;
|
610 | 629 | case MERCHANT_ID:
|
611 | 630 | this.setSellerId(prop.getProperty(property));
|
@@ -681,7 +700,7 @@ private PayConfig loadConfigurationFromProperties(Properties prop) {
|
681 | 700 | private boolean checkIfRequriedPropertiesExist() {
|
682 | 701 | if (this.accessKey == null)
|
683 | 702 | generateException(Key.ACCESS_KEY);
|
684 |
| - else if (this.secretKey == null) |
| 703 | + else if (this.secretKey == null || this.secretKey.length == 0) |
685 | 704 | generateException(Key.SECRET_KEY);
|
686 | 705 | else if (this.merchantId == null)
|
687 | 706 | generateException(Key.MERCHANT_ID);
|
@@ -711,7 +730,6 @@ private void generateException(Key propertyKey) {
|
711 | 730 | public String toString() {
|
712 | 731 | return "PayConfig{" +
|
713 | 732 | "accessKeyId=" + accessKey +
|
714 |
| - ", secretAccessKey=" + secretKey + |
715 | 733 | ", sellerId=" + merchantId +
|
716 | 734 | ", region=" + region +
|
717 | 735 | ", environment=" + environment +
|
|
0 commit comments