ClientSecretHelper.java
994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
*
*/
package com.yoho.unions.helper;
import com.yoho.unions.interceptor.SecurityInterceptor;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* 描述:
*
* @author ping.huang
* 2016年4月1日
*/
@Component
public class ClientSecretHelper {
@Resource
SecurityInterceptor securityInterceptor;
/**
* 生产client_secret
* @param map
*/
public String createClientSecret(Map<String, String> map) {
if (MapUtils.isEmpty(map)) {
return null;
}
map.put("v", "7");
map.put("client_secret", securityInterceptor.getSign(map));
List<String> list = new ArrayList<String>();
for (Entry<String, String> entry : map.entrySet()) {
list.add(entry.getKey() + "=" + entry.getValue());
}
return StringUtils.join(list, "&");
}
}