Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private WxCpService wxCpService(WxCpConfigStorage wxCpConfigStorage, WxCpMultiPr
private void configCorp(WxCpDefaultConfigImpl config, WxCpSingleProperties wxCpSingleProperties) {
String corpId = wxCpSingleProperties.getCorpId();
String corpSecret = wxCpSingleProperties.getCorpSecret();
Integer agentId = wxCpSingleProperties.getAgentId();
Long agentId = wxCpSingleProperties.getAgentId();
String token = wxCpSingleProperties.getToken();
String aesKey = wxCpSingleProperties.getAesKey();
// 企业微信,私钥,会话存档路径
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class WxCpSingleProperties implements Serializable {
* <p>使用自建应用 Secret 时,需要填写对应应用的 AgentId。</p>
* <p>使用通讯录同步 Secret 时,无需填写此字段。</p>
*/
private Integer agentId;
private Long agentId;
/**
* 微信企业号应用 EncodingAESKey
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class WxCpProperties {
/**
* 微信企业号应用 ID
*/
private Integer agentId;
private Long agentId;
/**
* 微信企业号应用 EncodingAESKey
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class AbstractWxCpConfigStorageConfiguration {
protected WxCpDefaultConfigImpl config(WxCpDefaultConfigImpl config, WxCpProperties properties) {
String corpId = properties.getCorpId();
String corpSecret = properties.getCorpSecret();
Integer agentId = properties.getAgentId();
Long agentId = properties.getAgentId();
String token = properties.getToken();
String aesKey = properties.getAesKey();
// 企业微信,私钥,会话存档路径
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class DataUtils {
*/
public static <E> E handleDataWithSecret(E data) {
E dataForLog = data;
if (data instanceof String && StringUtils.contains((String) data, "secret=")) {
dataForLog = (E) RegExUtils.replaceAll((String) data, "(^|[?&])secret=[^&]*", "$1secret=******");
if (data instanceof String) {
String stringData = (String) data;
stringData = RegExUtils.replaceAll(stringData, "(^|[?&])secret=[^&]*", "$1secret=******");
dataForLog = (E) RegExUtils.replaceAll(stringData, "(\\\"openid\\\"\\s*:\\s*\\\")[^\\\"]*(\\\")", "$1******$2");
}
return dataForLog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ public void testHandleDataWithSecretEncodedValue() {
assertFalse(s.contains("%2F"), "Encoded characters in the secret must be masked too");
assertTrue(s.contains("&secret=******&"), "Secret should be replaced with asterisks");
}

@Test
public void testHandleDataWithOpenidInJson() {
String data = "{\"code\":\"phone-code\",\"openid\":\"user-openid\"}";

String result = DataUtils.handleDataWithSecret(data);

assertFalse(result.contains("user-openid"));
assertTrue(result.contains("\"openid\":\"******\""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface WxCpAgentService {
* @return wx cp agent
* @throws WxErrorException the wx error exception
*/
WxCpAgent get(Integer agentId) throws WxErrorException;
WxCpAgent get(Long agentId) throws WxErrorException;
Comment thread
binarywang marked this conversation as resolved.

/**
* <pre>
Expand Down Expand Up @@ -65,6 +65,6 @@ public interface WxCpAgentService {
* @return admin list
* @throws WxErrorException the wx error exception
*/
WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException;
WxCpTpAdmin getAdminList(Long agentId) throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public interface WxCpCorpGroupService {
* @return the list
* @throws WxErrorException the wx error exception
*/
List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException;
List<WxCpCorpGroupCorp> listAppShareInfo(Long agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface WxCpMenuService {
* @throws WxErrorException the wx error exception
* @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) #create(me.chanjar.weixin.common.bean.menu.WxMenu)
*/
void create(Integer agentId, WxMenu menu) throws WxErrorException;
void create(Long agentId, WxMenu menu) throws WxErrorException;

/**
* <pre>
Expand All @@ -67,7 +67,7 @@ public interface WxCpMenuService {
* @throws WxErrorException the wx error exception
* @see #delete() #delete()
*/
void delete(Integer agentId) throws WxErrorException;
void delete(Long agentId) throws WxErrorException;

/**
* <pre>
Expand Down Expand Up @@ -96,5 +96,5 @@ public interface WxCpMenuService {
* @throws WxErrorException the wx error exception
* @see #get() #get()
*/
WxMenu get(Integer agentId) throws WxErrorException;
WxMenu get(Long agentId) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public interface WxCpOAuth2Service {
* @throws WxErrorException 异常
* @see #getUserInfo(String) #getUserInfo(String)
*/
WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException;
WxCpOauth2UserInfo getUserInfo(Long agentId, String code) throws WxErrorException;

/**
* 获取家校访问用户身份
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
private final WxCpService mainService;

@Override
public WxCpAgent get(Integer agentId) throws WxErrorException {
public WxCpAgent get(Long agentId) throws WxErrorException {
Comment thread
binarywang marked this conversation as resolved.
if (agentId == null) {
throw new IllegalArgumentException("缺少agentid参数");
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public List<WxCpAgent> list() throws WxErrorException {
}

@Override
public WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException {
public WxCpTpAdmin getAdminList(Long agentId) throws WxErrorException {
if (agentId == null) {
throw new IllegalArgumentException("缺少agentid参数");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService {
private final WxCpService cpService;

@Override
public List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId,
public List<WxCpCorpGroupCorp> listAppShareInfo(Long agentId, Integer businessType, String corpId,
Integer limit, String cursor) throws WxErrorException {
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO);
JsonObject jsonObject = new JsonObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void create(WxMenu menu) throws WxErrorException {
}

@Override
public void create(Integer agentId, WxMenu menu) throws WxErrorException {
public void create(Long agentId, WxMenu menu) throws WxErrorException {
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_CREATE), agentId);
this.mainService.post(url, menu.toJson());
}
Expand All @@ -38,7 +38,7 @@ public void delete() throws WxErrorException {
}

@Override
public void delete(Integer agentId) throws WxErrorException {
public void delete(Long agentId) throws WxErrorException {
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_DELETE), agentId);
this.mainService.get(url, null);
}
Expand All @@ -49,7 +49,7 @@ public WxMenu get() throws WxErrorException {
}

@Override
public WxMenu get(Integer agentId) throws WxErrorException {
public WxMenu get(Long agentId) throws WxErrorException {
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_GET), agentId);
try {
String resultContent = this.mainService.get(url, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {

@Override
public WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException {
Integer agentId = message.getAgentId();
Long agentId = message.getAgentId();
if (null == agentId) {
message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
}
Expand All @@ -38,7 +38,7 @@ public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorExcep

@Override
public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
Integer agentId = message.getAgentId();
Long agentId = message.getAgentId();
if (null == agentId) {
message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public WxCpOauth2UserInfo getUserInfo(String code) throws WxErrorException {
}

@Override
public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException {
public WxCpOauth2UserInfo getUserInfo(Long agentId, String code) throws WxErrorException {
String responseText =
this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_INFO), code,
agentId), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class WxCpTaskCardServiceImpl implements WxCpTaskCardService {

@Override
public void update(List<String> userIds, String taskId, String replaceName) throws WxErrorException {
Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
Long agentId = this.mainService.getWxCpConfigStorage().getAgentId();

Map<String, Object> data = new HashMap<>(4);
data.put("userids", userIds);
Expand All @@ -45,7 +45,7 @@ public void update(List<String> userIds, String taskId, String replaceName) thro
public void updateTemplateCardButton(List<String> userIds, List<Integer> partyIds,
List<Integer> tagIds, Integer atAll,
String responseCode, String replaceName) throws WxErrorException {
Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
Long agentId = this.mainService.getWxCpConfigStorage().getAgentId();
Map<String, Object> data = new HashMap<>(7);
data.put("userids", userIds);
data.put("partyids", partyIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class WxCpAgent implements Serializable {
private String errMsg;

@SerializedName("agentid")
private Integer agentId;
private Long agentId;

@SerializedName("name")
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WxCpAgentJsapiSignature implements Serializable {

private String corpid;

private Integer agentid;
private Long agentid;

private long timestamp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class WxCpCorpGroupCorpGetTokenReq implements Serializable {
@SerializedName("business_type")
private int businessType;
@SerializedName("agentid")
private int agentId;
private long agentId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ public class WxCpLinkedCorpMessage implements Serializable {
/**
* 企业应用的id,整型。可在应用的设置页面查看
*/
private Integer agentId;
private Long agentId;

public void setAgentId(long agentId) {
this.agentId = Long.valueOf(agentId);
}

public void setAgentId(Long agentId) {
this.agentId = agentId;
}
private String msgType;
/**
* 消息内容,最长不超过2048个字节
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ public class WxCpMessage implements Serializable {
/**
* 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
*/
private Integer agentId;
private Long agentId;

public void setAgentId(long agentId) {
Comment thread
binarywang marked this conversation as resolved.
this.agentId = Long.valueOf(agentId);
}

public void setAgentId(Long agentId) {
this.agentId = agentId;
}
/**
* 消息类型
* 文本消息: text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ public class WxCpSchoolContactMessage implements Serializable {
* 企业应用的id,整型。可在应用的设置页面查看
*/
@SerializedName("agentid")
private Integer agentId;
private Long agentId;

public void setAgentId(long agentId) {
this.agentId = Long.valueOf(agentId);
}

public void setAgentId(Long agentId) {
this.agentId = agentId;
}

/**
* 消息内容,最长不超过2048个字节(支持id转译)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class BaseBuilder<T> {
/**
* The Agent id.
*/
protected Integer agentId;
protected Long agentId;
/**
* The To user.
*/
Expand All @@ -39,11 +39,15 @@ public abstract class BaseBuilder<T> {
* @param agentId the agent id
* @return the t
*/
public T agentId(Integer agentId) {
public T agentId(Long agentId) {
this.agentId = agentId;
return (T) this;
}

public T agentId(long agentId) {
return this.agentId(Long.valueOf(agentId));
}

/**
* To user t.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public interface WxCpConfigStorage {
*
* @return the agent id
*/
Integer getAgentId();
Long getAgentId();
Comment thread
binarywang marked this conversation as resolved.
Comment thread
binarywang marked this conversation as resolved.

/**
* Gets token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface WxCpCorpGroupConfigStorage {
* @param corpAccessToken the corp access token
* @param expiresInSeconds the expires in seconds
*/
void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds);
void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds);

/**
* 授权企业的access token相关
Expand All @@ -45,7 +45,7 @@ public interface WxCpCorpGroupConfigStorage {
* @param agentId 应用ID
* @return the access token
*/
String getCorpAccessToken(String corpId, Integer agentId);
String getCorpAccessToken(String corpId, Long agentId);

/**
* Gets access token entity.
Expand All @@ -54,7 +54,7 @@ public interface WxCpCorpGroupConfigStorage {
* @param agentId 应用ID
* @return the access token entity
*/
WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId);
WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId);

/**
* Is access token expired boolean.
Expand All @@ -63,15 +63,15 @@ public interface WxCpCorpGroupConfigStorage {
* @param agentId 应用ID
* @return the boolean
*/
boolean isCorpAccessTokenExpired(String corpId, Integer agentId);
boolean isCorpAccessTokenExpired(String corpId, Long agentId);

/**
* Expire access token.
*
* @param corpId 企业ID
* @param agentId 应用ID
*/
void expireCorpAccessToken(String corpId, Integer agentId);
void expireCorpAccessToken(String corpId, Long agentId);

/**
* 网络代理相关
Expand Down Expand Up @@ -122,11 +122,11 @@ public interface WxCpCorpGroupConfigStorage {
* @param agentId 应用ID
* @return the access token lock
*/
Lock getCorpAccessTokenLock(String corpId, Integer agentId);
Lock getCorpAccessTokenLock(String corpId, Long agentId);

void setCorpId(String corpId);

void setAgentId(Integer agentId);
void setAgentId(Long agentId);

/**
* Gets corp id.
Expand All @@ -140,5 +140,5 @@ public interface WxCpCorpGroupConfigStorage {
*
* @return the agent id
*/
Integer getAgentId();
Long getAgentId();
}
Loading