2
2
* Ant Group
3
3
* Copyright (c) 2004-2024 All Rights Reserved.
4
4
*/
5
- package com .alipay .global .api .request .ams .risk .tee .encryptstrategy ;
5
+ package com .alipay .global .api .request .ams .risk .tee .encryptutil ;
6
6
7
7
import com .alipay .global .api .model .ams .UserName ;
8
8
import com .alipay .global .api .model .risk .Order ;
21
21
* request encrypt strategy for risk decide API
22
22
* risk decide API 的请求加密策略
23
23
*/
24
- public class RiskDecideEncryptStrategy implements EncryptStrategy {
24
+ public class RiskDecideEncryptUtil {
25
25
26
- Charset utf8Charset = Charset .forName ("UTF-8" );
26
+ private static Charset utf8Charset = Charset .forName ("UTF-8" );
27
27
28
- @ Override
29
- public void encrypt (byte [] data_key , AlipayRequest <?> request , List <EncryptKeyEnum > encryptKeyList ) {
28
+ public static void encrypt (String dataKeyBase64 , AlipayRequest <?> request , List <EncryptKeyEnum > encryptKeyList ) {
30
29
if (request == null || encryptKeyList == null ) {
31
30
return ;
32
31
}
33
32
if (!(request instanceof RiskDecideRequest )) {
34
- throw new CryptoException (ErrorCodeEnum .MISMATCH_ENCRYPT_STRATEGY , "Request is not instance of RiskDecideRequest" );
33
+ throw new CryptoException (ErrorCodeEnum .MISMATCH_ENCRYPT_UTIL , "Request is not instance of RiskDecideRequest" );
35
34
}
36
35
RiskDecideRequest riskDecideRequest = (RiskDecideRequest ) request ;
37
36
AESCrypto crypto = AESCrypto .getInstance ();
38
- doEncrypt (data_key , riskDecideRequest , encryptKeyList , crypto );
39
- }
40
-
41
- @ Override
42
- public void encrypt (String dataKeyBase64 , AlipayRequest <?> request , List <EncryptKeyEnum > encryptKeyList ) {
43
- encrypt (DatatypeConverter .parseBase64Binary (dataKeyBase64 ), request , encryptKeyList );
37
+ doEncrypt (DatatypeConverter .parseBase64Binary (dataKeyBase64 ), riskDecideRequest , encryptKeyList , crypto );
44
38
}
45
39
46
40
/**
@@ -51,7 +45,7 @@ public void encrypt(String dataKeyBase64, AlipayRequest<?> request, List<Encrypt
51
45
* @param encryptKeyList list of encrypt keys
52
46
* @param crypto AESCrypto instance
53
47
*/
54
- private void doEncrypt (byte [] data_key , RiskDecideRequest request , List <EncryptKeyEnum > encryptKeyList ,
48
+ private static void doEncrypt (byte [] data_key , RiskDecideRequest request , List <EncryptKeyEnum > encryptKeyList ,
55
49
AESCrypto crypto ) {
56
50
List <Order > orders = request .getOrders ();
57
51
List <PaymentDetail > paymentDetails = request .getPaymentDetails ();
@@ -148,7 +142,7 @@ private void doEncrypt(byte[] data_key, RiskDecideRequest request, List<EncryptK
148
142
* @param userName user name
149
143
* @param crypto AESCrypto instance
150
144
*/
151
- private void encryptName (byte [] data_key , UserName userName , AESCrypto crypto ) {
145
+ private static void encryptName (byte [] data_key , UserName userName , AESCrypto crypto ) {
152
146
if (userName == null ) {
153
147
return ;
154
148
}
0 commit comments