public class SecurityClient extends Object implements SecurityConstants
BETA_STATUS, CURRENT, CURRENT_NICK_ENCRYPT_TYPE, CURRENT_PHONE_ENCRYPT_TYPE, CURRENT_RECEIVER_NAME_ENCRYPT_TYPE, DEFAULT_ENCRYPT_SLIDE_SIZE, DEFAULT_INDEX_ENCRYPT_COMPRESS_LEN, DEFAULT_INTERVAL, DEFAULT_MAX_INTERVAL, ENCRYPT_INDEX_COMPRESS_LEN, ENCRYPT_SLIDE_SIZE, INDEX_ENCRYPT_TYPE, NICK, NICK_SEPARATOR, NICK_SEPARATOR_CHAR, NORMAL, NORMAL_ENCRYPT_TYPE, NORMAL_SEPARATOR, NORMAL_SEPARATOR_CHAR, PHONE, PHONE_SEPARATOR, PHONE_SEPARATOR_CHAR, PREVIOUS, PREVIOUS_NICK_ENCRYPT_TYPE, PREVIOUS_PHONE_ENCRYPT_TYPE, PREVIOUS_RECEIVER_NAME_ENCRYPT_TYPE, PUBLISH_STATUS, RECEIVER_NAME, SEARCH, SIMPLE, SIMPLE_CHAR, SIMPLE_SEPARATOR, UNDERLINE| Constructor and Description |
|---|
SecurityClient(DefaultTaobaoClient taobaoClient,
String randomNum) |
SecurityClient(DefaultTaobaoClient taobaoClient,
String randomNum,
boolean streetest) |
SecurityClient(DefaultTaobaoClient taobaoClient,
String randomNum,
int corePoolSize,
int maxPoolSize,
int maxQueue,
boolean streetest) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,String> |
decrypt(List<String> dataList,
String type)
批量解密(所有用户共用秘钥)
|
Map<String,String> |
decrypt(List<String> dataList,
String type,
String session)
批量解密(每个用户单独分配秘钥)
|
String |
decrypt(String data,
String type)
解密(所有用户共用秘钥)
|
String |
decrypt(String data,
String type,
String session)
解密(每个用户单独分配秘钥)
|
Map<String,String> |
encrypt(List<String> dataList,
String type)
批量加密(所有用户共用秘钥)
|
Map<String,String> |
encrypt(List<String> dataList,
String type,
String session)
批量加密(每个用户单独分配秘钥)
|
String |
encrypt(String data,
String type)
加密(所有用户共用秘钥)
|
String |
encrypt(String data,
String type,
String session)
加密(每个用户单独分配秘钥)
|
String |
encryptPrevious(String data,
String type)
用老秘钥加密,只在秘钥升级时使用(所有用户共用秘钥)
|
String |
encryptPrevious(String data,
String type,
String session)
用老秘钥加密,只在秘钥升级时使用(每个用户单独分配秘钥)
|
static String |
generateCustomerSession(long userId)
生成自定义session,提供给自主账号使用
|
void |
initSecret()
初始化秘钥(如果半小时内会调用加、解密方法,建议先初始化秘钥)。所有用户共用秘钥
|
void |
initSecret(String session)
初始化秘钥(如果半小时内会调用加、解密方法,建议先初始化秘钥)。每个用户单独分配秘钥
|
static boolean |
isEncryptData(List<String> dataList,
String type)
判断list元素是否全部为密文数据
|
static boolean |
isEncryptData(String data,
String type)
判断是否密文数据
|
static boolean |
isPartEncryptData(List<String> dataList,
String type)
判断list元素是否存在密文数据。只要有一个是密文,则返回true
|
String |
search(String data,
String type)
密文检索(所有用户共用秘钥)
|
String |
search(String data,
String type,
String session)
密文检索(每个用户单独分配秘钥)
|
String |
searchPrevious(String data,
String type)
密文检索,在秘钥升级场景下兼容查询(所有用户共用秘钥)
|
String |
searchPrevious(String data,
String type,
String session)
密文检索,在秘钥升级场景下兼容查询(每个用户单独分配秘钥)
|
void |
setRandomNum(String randomNum) |
static void |
shutdown()
Deprecated.
|
public SecurityClient(DefaultTaobaoClient taobaoClient, String randomNum)
defaultTaobaoClient - serverUrl必须是https协议randomNum - 伪随机码public SecurityClient(DefaultTaobaoClient taobaoClient, String randomNum, boolean streetest)
defaultTaobaoClient - serverUrl必须是https协议randomNum - 伪随机码streetest - 是否全链路压测public SecurityClient(DefaultTaobaoClient taobaoClient, String randomNum, int corePoolSize, int maxPoolSize, int maxQueue, boolean streetest)
taobaoClient - serverUrl必须是https协议randomNum - 伪随机码corePoolSize - 核心线程数maxPoolSize - 最大线程数maxQueue - 线程池最大队列streetest - 是否全链路压测public void initSecret()
throws ApiException
ApiExceptionpublic void setRandomNum(String randomNum)
public void initSecret(String session) throws ApiException
session - ApiExceptionpublic Map<String,String> decrypt(List<String> dataList, String type) throws SecretException
dataList - type - SecretExceptiondecrypt(List, String, String)public Map<String,String> decrypt(List<String> dataList, String type, String session) throws SecretException
dataList - type - session - SecretExceptiondecrypt(String, String, String)public String decrypt(String data, String type) throws SecretException
data - type - SecretExceptiondecrypt(String, String, String)public String decrypt(String data, String type, String session) throws SecretException
data - 密文数据 手机号码格式:$手机号码前3位明文$base64(encrypt(phone后8位))$111$
simple格式:~base64(encrypt(nick))~111~type - 解密字段类型(例如:simple\phone)session - 用户身份,用户级加密必填SecretExceptionpublic static boolean isEncryptData(List<String> dataList, String type) throws SecretException
dataList - type - 加密字段类型(例如:simple\phone)SecretExceptionisEncryptData(String, String)public static boolean isPartEncryptData(List<String> dataList, String type) throws SecretException
dataList - type - 加密字段类型(例如:simple\phone)SecretExceptionpublic static boolean isEncryptData(String data, String type) throws SecretException
data - type - 加密字段类型(例如:simple\phone)SecretExceptionpublic String encrypt(String data, String type) throws SecretException
data - type - SecretExceptionencrypt(String, String, String, Long)public String encryptPrevious(String data, String type) throws SecretException
data - type - SecretExceptionencrypt(String, String, String, Long)public String encrypt(String data, String type, String session) throws SecretException
SecretExceptionencrypt(String, String, String, Long)public String encryptPrevious(String data, String type, String session) throws SecretException
SecretExceptionencrypt(String, String, String, Long)public String search(String data, String type) throws SecretException
SecretExceptionsearch(String, String, String, Long)public String searchPrevious(String data, String type) throws SecretException
SecretExceptionsearch(String, String, String, Long)public String search(String data, String type, String session) throws SecretException
SecretExceptionsearch(String, String, String, Long)public String searchPrevious(String data, String type, String session) throws SecretException
SecretExceptionsearch(String, String, String, Long)public Map<String,String> encrypt(List<String> dataList, String type) throws SecretException
dataList - type - SecretExceptionencrypt(List, String, String)public Map<String,String> encrypt(List<String> dataList, String type, String session) throws SecretException
dataList - type - session - SecretExceptionencrypt(String, String, String, Long)public static String generateCustomerSession(long userId)
userId - @Deprecated public static void shutdown()
Copyright © 2021. All rights reserved.