mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
JsonUtils rename method name
This commit is contained in:
parent
5617aa5c94
commit
d22358bb98
@ -124,7 +124,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
|
|||||||
//String responseString = "{\"code\":200,\"msg\":\"1\",\"obj\":\"740673\"}";
|
//String responseString = "{\"code\":200,\"msg\":\"1\",\"obj\":\"740673\"}";
|
||||||
logger.debug("responseString " + responseString);
|
logger.debug("responseString " + responseString);
|
||||||
YunxinSms yunxinSms =
|
YunxinSms yunxinSms =
|
||||||
JsonUtils.gson2Object(responseString,YunxinSms.class);
|
JsonUtils.gsonStringToObject(responseString,YunxinSms.class);
|
||||||
logger.debug("responseEntity code " + yunxinSms.getObj());
|
logger.debug("responseEntity code " + yunxinSms.getObj());
|
||||||
nonce = yunxinSms.getObj() == null ?nonce:yunxinSms.getObj();
|
nonce = yunxinSms.getObj() == null ?nonce:yunxinSms.getObj();
|
||||||
logger.debug("nonce " + nonce);
|
logger.debug("nonce " + nonce);
|
||||||
@ -226,7 +226,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
|
|||||||
).randomGenerate();
|
).randomGenerate();
|
||||||
System.out.println(nonce);
|
System.out.println(nonce);
|
||||||
String mapJson = "{\"code\":200,\"msg\":\"1\",\"obj\":\"740673\"}";
|
String mapJson = "{\"code\":200,\"msg\":\"1\",\"obj\":\"740673\"}";
|
||||||
YunxinSms yunxinSms = JsonUtils.gson2Object(mapJson,YunxinSms.class);
|
YunxinSms yunxinSms = JsonUtils.gsonStringToObject(mapJson,YunxinSms.class);
|
||||||
System.out.println("code " + yunxinSms.getObj());
|
System.out.println("code " + yunxinSms.getObj());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class HttpKerberosEntryPoint implements AsyncHandlerInterceptor {
|
|||||||
}
|
}
|
||||||
_logger.debug("decoder Kerberos Token "+decoderKerberosToken);
|
_logger.debug("decoder Kerberos Token "+decoderKerberosToken);
|
||||||
KerberosToken kerberosToken=new KerberosToken();
|
KerberosToken kerberosToken=new KerberosToken();
|
||||||
kerberosToken=(KerberosToken)JsonUtils.json2Object(decoderKerberosToken, kerberosToken);
|
kerberosToken=(KerberosToken)JsonUtils.stringToObject(decoderKerberosToken, kerberosToken);
|
||||||
_logger.debug("Kerberos Token "+kerberosToken);
|
_logger.debug("Kerberos Token "+kerberosToken);
|
||||||
|
|
||||||
DateTime notOnOrAfter=DateUtils.toUtcDate(kerberosToken.getNotOnOrAfter());
|
DateTime notOnOrAfter=DateUtils.toUtcDate(kerberosToken.getNotOnOrAfter());
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class RemoteKerberosService implements KerberosService{
|
|||||||
userDomainUrlList.add(userDomainUrl);
|
userDomainUrlList.add(userDomainUrl);
|
||||||
}
|
}
|
||||||
_logger.debug(""+userDomainUrlList);
|
_logger.debug(""+userDomainUrlList);
|
||||||
String userDomainUrlJson=JsonUtils.object2Json(userDomainUrlList);
|
String userDomainUrlJson=JsonUtils.toString(userDomainUrlList);
|
||||||
_logger.debug("userDomain Url Json "+userDomainUrlJson);
|
_logger.debug("userDomain Url Json "+userDomainUrlJson);
|
||||||
return userDomainUrlJson;
|
return userDomainUrlJson;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,13 +27,13 @@ import java.io.IOException;
|
|||||||
public class JsonUtils {
|
public class JsonUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform json string to java bean object.
|
* jackson Transform json string to java bean object.
|
||||||
*
|
*
|
||||||
* @param json String
|
* @param json String
|
||||||
* @param bean Object
|
* @param bean Object
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
public static Object json2Object(String json, Object bean) {
|
public static Object stringToObject(String json, Object bean) {
|
||||||
try {
|
try {
|
||||||
bean = (new ObjectMapper()).readValue(json, bean.getClass());
|
bean = (new ObjectMapper()).readValue(json, bean.getClass());
|
||||||
} catch (JsonParseException e) {
|
} catch (JsonParseException e) {
|
||||||
@ -47,13 +47,13 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform json string to java bean object.
|
* jackson Transform json string to java bean object.
|
||||||
*
|
*
|
||||||
* @param json String
|
* @param json String
|
||||||
* @param cls Class
|
* @param cls Class
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
public static <T> T json2Object(String json, Class<T> cls) {
|
public static <T> T stringToObject(String json, Class<T> cls) {
|
||||||
T bean = null;
|
T bean = null;
|
||||||
try {
|
try {
|
||||||
bean = (new ObjectMapper()).readValue(json, cls);
|
bean = (new ObjectMapper()).readValue(json, cls);
|
||||||
@ -68,12 +68,12 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform java bean object to json string.
|
* jackson Transform java bean object to json string.
|
||||||
*
|
*
|
||||||
* @param bean Object
|
* @param bean Object
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static String object2Json(Object bean) {
|
public static String toString(Object bean) {
|
||||||
String json = "";
|
String json = "";
|
||||||
try {
|
try {
|
||||||
json = (new ObjectMapper()).writeValueAsString(bean);
|
json = (new ObjectMapper()).writeValueAsString(bean);
|
||||||
@ -88,25 +88,25 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform json string to java bean object use Gson.
|
* Gson Transform json string to java bean object.
|
||||||
*
|
*
|
||||||
* @param <T> Class
|
* @param <T> Class
|
||||||
* @param json String
|
* @param json String
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static <T> T gson2Object(String json, Class<T> cls) {
|
public static <T> T gsonStringToObject(String json, Class<T> cls) {
|
||||||
T newBean = (new Gson()).fromJson(json, cls);
|
T newBean = (new Gson()).fromJson(json, cls);
|
||||||
return newBean;
|
return newBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform java bean object to json string use Gson.
|
* Gson Transform java bean object to json string .
|
||||||
*
|
*
|
||||||
* @param bean Object
|
* @param bean Object
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static String gson2Json(Object bean) {
|
public static String gsonToString(Object bean) {
|
||||||
String json = "";
|
String json = "";
|
||||||
// convert java object to JSON format,
|
// convert java object to JSON format,
|
||||||
// and returned as JSON formatted string
|
// and returned as JSON formatted string
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class ExtraAttrs {
|
|||||||
public ExtraAttrs(String arrayJsonString) {
|
public ExtraAttrs(String arrayJsonString) {
|
||||||
String extraAttrsJsonString= "{\"extraAttrs\":"+arrayJsonString+"}";
|
String extraAttrsJsonString= "{\"extraAttrs\":"+arrayJsonString+"}";
|
||||||
_logger.debug("Extra Attrs Json String " +extraAttrsJsonString);
|
_logger.debug("Extra Attrs Json String " +extraAttrsJsonString);
|
||||||
ExtraAttrs extraAttrs=JsonUtils.gson2Object(extraAttrsJsonString, ExtraAttrs.class);
|
ExtraAttrs extraAttrs=JsonUtils.gsonStringToObject(extraAttrsJsonString, ExtraAttrs.class);
|
||||||
this.extraAttrs=extraAttrs.getExtraAttrs();
|
this.extraAttrs=extraAttrs.getExtraAttrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class ExtraAttrs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toJsonString(){
|
public String toJsonString(){
|
||||||
String jsonString =JsonUtils.gson2Json(extraAttrs);
|
String jsonString =JsonUtils.gsonToString(extraAttrs);
|
||||||
_logger.debug("jsonString " +jsonString);
|
_logger.debug("jsonString " +jsonString);
|
||||||
return jsonString;
|
return jsonString;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,7 +108,7 @@ public class HttpRequestAdapter {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}else if(mediaType.equals(ContentType.APPLICATION_JSON)) {
|
}else if(mediaType.equals(ContentType.APPLICATION_JSON)) {
|
||||||
String jsonString = JsonUtils.gson2Json(parameterMap);
|
String jsonString = JsonUtils.gsonToString(parameterMap);
|
||||||
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
||||||
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
||||||
httpMethod.setEntity(stringEntity);
|
httpMethod.setEntity(stringEntity);
|
||||||
@ -148,7 +148,7 @@ public class HttpRequestAdapter {
|
|||||||
buildHeader(httpMethod,headers);
|
buildHeader(httpMethod,headers);
|
||||||
|
|
||||||
// 封装put请求参数
|
// 封装put请求参数
|
||||||
String jsonString = JsonUtils.gson2Json(data);
|
String jsonString = JsonUtils.gsonToString(data);
|
||||||
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
||||||
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
||||||
httpMethod.setEntity(stringEntity);
|
httpMethod.setEntity(stringEntity);
|
||||||
@ -185,7 +185,7 @@ public class HttpRequestAdapter {
|
|||||||
buildHeader(httpMethod,headers);
|
buildHeader(httpMethod,headers);
|
||||||
|
|
||||||
// 封装put请求参数
|
// 封装put请求参数
|
||||||
String jsonString = JsonUtils.gson2Json(data);
|
String jsonString = JsonUtils.gsonToString(data);
|
||||||
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
|
||||||
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
stringEntity.setContentType(ContentType.APPLICATION_JSON);
|
||||||
httpMethod.setEntity(stringEntity);
|
httpMethod.setEntity(stringEntity);
|
||||||
|
|||||||
@ -25,10 +25,10 @@ public class ScimEnterpriseUserJsonString2ObjectTest {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
String userJsonString = ReadJson2String.read("ScimEnterpriseUserJsonString.json");
|
String userJsonString = ReadJson2String.read("ScimEnterpriseUserJsonString.json");
|
||||||
ScimEnterpriseUser u = JsonUtils.json2Object(userJsonString, ScimEnterpriseUser.class);
|
ScimEnterpriseUser u = JsonUtils.stringToObject(userJsonString, ScimEnterpriseUser.class);
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||||
System.out.println(u.getEnterprise().getCostCenter());
|
System.out.println(u.getEnterprise().getCostCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public class ScimEnterpriseUserJsonTest {
|
|||||||
u.setEnterprise(ent);
|
u.setEnterprise(ent);
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,10 +23,10 @@ import org.maxkey.util.JsonUtils;
|
|||||||
public class ScimGroupJsonString2ObjectTest {
|
public class ScimGroupJsonString2ObjectTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String userJsonString = ReadJson2String.read("ScimGroupJsonString.json");
|
String userJsonString = ReadJson2String.read("ScimGroupJsonString.json");
|
||||||
ScimGroup g = JsonUtils.json2Object(userJsonString, ScimGroup.class);
|
ScimGroup g = JsonUtils.stringToObject(userJsonString, ScimGroup.class);
|
||||||
|
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(g)));
|
(new JsonPretty()).format(JsonUtils.toString(g)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,6 @@ public class ScimGroupJsonTest {
|
|||||||
g.setMembers(mrSet);
|
g.setMembers(mrSet);
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(g)));
|
(new JsonPretty()).format(JsonUtils.toString(g)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,9 @@ public class ScimUserJsonString2ObjectTest {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
String userJsonString = ReadJson2String.read("ScimUserJsonString.json");
|
String userJsonString = ReadJson2String.read("ScimUserJsonString.json");
|
||||||
ScimUser u = JsonUtils.json2Object(userJsonString, ScimUser.class);
|
ScimUser u = JsonUtils.stringToObject(userJsonString, ScimUser.class);
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public class ScimUserJsonTest {
|
|||||||
u.setEmails(ueList);
|
u.setEmails(ueList);
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class HistorySystemLogsService extends JpaBaseService<HistorySystemLogs>
|
|||||||
systemLog.setUsername(operator.getUsername());
|
systemLog.setUsername(operator.getUsername());
|
||||||
systemLog.setDisplayName(operator.getDisplayName());
|
systemLog.setDisplayName(operator.getDisplayName());
|
||||||
systemLog.setInstId(operator.getInstId());
|
systemLog.setInstId(operator.getInstId());
|
||||||
systemLog.setJsonCotent(JsonUtils.gson2Json(entity));
|
systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
|
||||||
_logger.trace("System Log {}" ,systemLog);
|
_logger.trace("System Log {}" ,systemLog);
|
||||||
getMapper().insert(systemLog);
|
getMapper().insert(systemLog);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public class ProvisioningRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void provisionLog(String conName,String topic,String actionType,String sourceId,String sourceName,String resultMessage,int instid) {
|
public void provisionLog(String conName,String topic,String actionType,String sourceId,String sourceName,String resultMessage,int instid) {
|
||||||
Message<?> resultMsg = JsonUtils.json2Object(resultMessage, Message.class);
|
Message<?> resultMsg = JsonUtils.stringToObject(resultMessage, Message.class);
|
||||||
String result = "success";
|
String result = "success";
|
||||||
if(resultMsg == null || resultMsg.getCode() != 0) {
|
if(resultMsg == null || resultMsg.getCode() != 0) {
|
||||||
result = "fail";
|
result = "fail";
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class ProvisioningThread extends Thread{
|
|||||||
public void run() {
|
public void run() {
|
||||||
_logger.debug("send message \n{}" ,new JsonPretty().jacksonFormat(msg.getSourceObject()));
|
_logger.debug("send message \n{}" ,new JsonPretty().jacksonFormat(msg.getSourceObject()));
|
||||||
msg.setContent(ObjectTransformer.serialize((Serializable)msg.getSourceObject()));
|
msg.setContent(ObjectTransformer.serialize((Serializable)msg.getSourceObject()));
|
||||||
Inst inst = JsonUtils.gson2Object(JsonUtils.gson2Json(msg.getSourceObject()), Inst.class);
|
Inst inst = JsonUtils.gsonStringToObject(JsonUtils.gsonToString(msg.getSourceObject()), Inst.class);
|
||||||
jdbcTemplate.update(PROVISION_INSERT_STATEMENT,
|
jdbcTemplate.update(PROVISION_INSERT_STATEMENT,
|
||||||
new Object[] {
|
new Object[] {
|
||||||
msg.getId(), msg.getTopic(), msg.getActionType(), msg.getContent(),
|
msg.getId(), msg.getTopic(), msg.getActionType(), msg.getContent(),
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class ExtendApiCndnsApiMailAdapter extends AbstractAuthorizeAdapter {
|
|||||||
String responseBody = new HttpRequestAdapter().post(
|
String responseBody = new HttpRequestAdapter().post(
|
||||||
String.format(ADMIN_AUTHKEY_URI,details.getPrincipal(),sign,timestamp),requestParamenter);
|
String.format(ADMIN_AUTHKEY_URI,details.getPrincipal(),sign,timestamp),requestParamenter);
|
||||||
|
|
||||||
HashMap<String, String> authKey=JsonUtils.gson2Object(responseBody, HashMap.class);
|
HashMap<String, String> authKey=JsonUtils.gsonStringToObject(responseBody, HashMap.class);
|
||||||
redirect_uri = authKey.get("adminUrl");
|
redirect_uri = authKey.get("adminUrl");
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
@ -110,7 +110,7 @@ public class ExtendApiCndnsApiMailAdapter extends AbstractAuthorizeAdapter {
|
|||||||
String responseBody = new HttpRequestAdapter().post(
|
String responseBody = new HttpRequestAdapter().post(
|
||||||
String.format(AUTHKEY_URI,details.getPrincipal(),sign,timestamp),requestParamenter);
|
String.format(AUTHKEY_URI,details.getPrincipal(),sign,timestamp),requestParamenter);
|
||||||
|
|
||||||
HashMap<String, String> authKey=JsonUtils.gson2Object(responseBody, HashMap.class);
|
HashMap<String, String> authKey=JsonUtils.gsonStringToObject(responseBody, HashMap.class);
|
||||||
redirect_uri=authKey.get("webmailUrl");
|
redirect_uri=authKey.get("webmailUrl");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public class ExtendApiQQExmailAdapter extends AbstractAuthorizeAdapter {
|
|||||||
String accessToken = tokenCache.getIfPresent(corpid);
|
String accessToken = tokenCache.getIfPresent(corpid);
|
||||||
if(accessToken == null) {
|
if(accessToken == null) {
|
||||||
String responseBody = new HttpRequestAdapter().get(String.format(TOKEN_URI,corpid,corpsecret),null);
|
String responseBody = new HttpRequestAdapter().get(String.format(TOKEN_URI,corpid,corpsecret),null);
|
||||||
Token token =JsonUtils.gson2Object(responseBody,Token.class);
|
Token token =JsonUtils.gsonStringToObject(responseBody,Token.class);
|
||||||
_logger.debug("access_token {}" , token);
|
_logger.debug("access_token {}" , token);
|
||||||
accessToken = token.getAccess_token();
|
accessToken = token.getAccess_token();
|
||||||
tokenCache.put(corpid, accessToken);
|
tokenCache.put(corpid, accessToken);
|
||||||
@ -108,7 +108,7 @@ public class ExtendApiQQExmailAdapter extends AbstractAuthorizeAdapter {
|
|||||||
_logger.debug("userId {}" , userId);
|
_logger.debug("userId {}" , userId);
|
||||||
String authKeyBody = new HttpRequestAdapter().get(String.format(AUTHKEY_URI,accessToken,userId),null);
|
String authKeyBody = new HttpRequestAdapter().get(String.format(AUTHKEY_URI,accessToken,userId),null);
|
||||||
|
|
||||||
ExMailLoginUrl exMailLoginUrl = JsonUtils.gson2Object(authKeyBody, ExMailLoginUrl.class);
|
ExMailLoginUrl exMailLoginUrl = JsonUtils.gsonStringToObject(authKeyBody, ExMailLoginUrl.class);
|
||||||
_logger.debug("LoginUrl {} " , exMailLoginUrl);
|
_logger.debug("LoginUrl {} " , exMailLoginUrl);
|
||||||
return exMailLoginUrl;
|
return exMailLoginUrl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class OAuthDefaultUserInfoAdapter extends AbstractAuthorizeAdapter {
|
|||||||
beanMap.put("institution", userInfo.getInstId());
|
beanMap.put("institution", userInfo.getInstId());
|
||||||
beanMap.put(WebConstants.ONLINE_TICKET_NAME, principal.getSession().getFormattedId());
|
beanMap.put(WebConstants.ONLINE_TICKET_NAME, principal.getSession().getFormattedId());
|
||||||
|
|
||||||
String info= JsonUtils.object2Json(beanMap);
|
String info= JsonUtils.toString(beanMap);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,7 @@ public class UserInfoEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!StringGenerator.uuidMatches(access_token)) {
|
if (!StringGenerator.uuidMatches(access_token)) {
|
||||||
httpResponseAdapter.write(response,JsonUtils.gson2Json(accessTokenFormatError(access_token)),"json");
|
httpResponseAdapter.write(response,JsonUtils.gsonToString(accessTokenFormatError(access_token)),"json");
|
||||||
}
|
}
|
||||||
|
|
||||||
OAuth2Authentication oAuth2Authentication =null;
|
OAuth2Authentication oAuth2Authentication =null;
|
||||||
@ -123,7 +123,7 @@ public class UserInfoEndpoint {
|
|||||||
HashMap<String,Object>authzException=new HashMap<String,Object>();
|
HashMap<String,Object>authzException=new HashMap<String,Object>();
|
||||||
authzException.put(OAuth2Exception.ERROR, e.getOAuth2ErrorCode());
|
authzException.put(OAuth2Exception.ERROR, e.getOAuth2ErrorCode());
|
||||||
authzException.put(OAuth2Exception.DESCRIPTION,e.getMessage());
|
authzException.put(OAuth2Exception.DESCRIPTION,e.getMessage());
|
||||||
httpResponseAdapter.write(response,JsonUtils.gson2Json(authzException),"json");
|
httpResponseAdapter.write(response,JsonUtils.gsonToString(authzException),"json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class UserInfoOIDCEndpoint {
|
|||||||
String access_token = AuthorizationHeaderUtils.resolveBearer(request);
|
String access_token = AuthorizationHeaderUtils.resolveBearer(request);
|
||||||
|
|
||||||
if (!StringGenerator.uuidMatches(access_token)) {
|
if (!StringGenerator.uuidMatches(access_token)) {
|
||||||
return JsonUtils.gson2Json(accessTokenFormatError(access_token));
|
return JsonUtils.gsonToString(accessTokenFormatError(access_token));
|
||||||
}
|
}
|
||||||
|
|
||||||
String principal="";
|
String principal="";
|
||||||
@ -275,7 +275,7 @@ public class UserInfoOIDCEndpoint {
|
|||||||
HashMap<String,Object>authzException=new HashMap<String,Object>();
|
HashMap<String,Object>authzException=new HashMap<String,Object>();
|
||||||
authzException.put(OAuth2Exception.ERROR, e.getOAuth2ErrorCode());
|
authzException.put(OAuth2Exception.ERROR, e.getOAuth2ErrorCode());
|
||||||
authzException.put(OAuth2Exception.DESCRIPTION,e.getMessage());
|
authzException.put(OAuth2Exception.DESCRIPTION,e.getMessage());
|
||||||
return JsonUtils.object2Json(authzException);
|
return JsonUtils.toString(authzException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ public class TokenBasedDefaultAdapter extends AbstractAuthorizeAdapter {
|
|||||||
|
|
||||||
beanMap.put("expires", expiresString);
|
beanMap.put("expires", expiresString);
|
||||||
|
|
||||||
token = JsonUtils.object2Json(beanMap);
|
token = JsonUtils.toString(beanMap);
|
||||||
_logger.debug("Token : {}",token);
|
_logger.debug("Token : {}",token);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class FeishuAccessTokenService {
|
|||||||
parameterMap.put("app_secret", appSecret);
|
parameterMap.put("app_secret", appSecret);
|
||||||
String responseBody = request.post(TOKEN_URL, parameterMap,null);
|
String responseBody = request.post(TOKEN_URL, parameterMap,null);
|
||||||
|
|
||||||
AccessToken accessToken = JsonUtils.gson2Object(responseBody, AccessToken.class);
|
AccessToken accessToken = JsonUtils.gsonStringToObject(responseBody, AccessToken.class);
|
||||||
_logger.debug("accessToken " + accessToken);
|
_logger.debug("accessToken " + accessToken);
|
||||||
if(accessToken.getErrcode()== 0){
|
if(accessToken.getErrcode()== 0){
|
||||||
return accessToken.getTenant_access_token();
|
return accessToken.getTenant_access_token();
|
||||||
|
|||||||
@ -104,7 +104,7 @@ public class FeishuOrganizationService extends AbstractSynchronizerService imple
|
|||||||
HashMap<String,String> headers =new HashMap<String,String>();
|
HashMap<String,String> headers =new HashMap<String,String>();
|
||||||
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
||||||
String responseBody = request.get(String.format(DEPTS_URL, deptId),headers);
|
String responseBody = request.get(String.format(DEPTS_URL, deptId),headers);
|
||||||
FeishuDeptsResponse deptsResponse =JsonUtils.gson2Object(responseBody, FeishuDeptsResponse.class);
|
FeishuDeptsResponse deptsResponse =JsonUtils.gsonStringToObject(responseBody, FeishuDeptsResponse.class);
|
||||||
|
|
||||||
_logger.trace("response : " + responseBody);
|
_logger.trace("response : " + responseBody);
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ public class FeishuOrganizationService extends AbstractSynchronizerService imple
|
|||||||
HashMap<String,String> headers =new HashMap<String,String>();
|
HashMap<String,String> headers =new HashMap<String,String>();
|
||||||
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
||||||
String responseBody = request.get(String.format(url, deptId),headers);
|
String responseBody = request.get(String.format(url, deptId),headers);
|
||||||
FeishuDeptsResponse deptsResponse =JsonUtils.gson2Object(responseBody, FeishuDeptsResponse.class);
|
FeishuDeptsResponse deptsResponse =JsonUtils.gsonStringToObject(responseBody, FeishuDeptsResponse.class);
|
||||||
|
|
||||||
_logger.trace("response : " + responseBody);
|
_logger.trace("response : " + responseBody);
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class FeishuUsersService extends AbstractSynchronizerService implements I
|
|||||||
HashMap<String,String> headers =new HashMap<String,String>();
|
HashMap<String,String> headers =new HashMap<String,String>();
|
||||||
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
headers.put("Authorization", AuthorizationHeaderUtils.createBearer(access_token));
|
||||||
String responseBody = request.get(String.format(USERS_URL,relatedOrg.getOriginId()),headers);
|
String responseBody = request.get(String.format(USERS_URL,relatedOrg.getOriginId()),headers);
|
||||||
FeishuUsersResponse usersResponse =JsonUtils.gson2Object(responseBody, FeishuUsersResponse.class);
|
FeishuUsersResponse usersResponse =JsonUtils.gsonStringToObject(responseBody, FeishuUsersResponse.class);
|
||||||
_logger.trace("response : " + responseBody);
|
_logger.trace("response : " + responseBody);
|
||||||
if(usersResponse.getCode() == 0 && usersResponse.getData().getItems() != null) {
|
if(usersResponse.getCode() == 0 && usersResponse.getData().getItems() != null) {
|
||||||
for(FeishuUsers feiShuUser : usersResponse.getData().getItems()) {
|
for(FeishuUsers feiShuUser : usersResponse.getData().getItems()) {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class WorkweixinAccessTokenService {
|
|||||||
HttpRequestAdapter request =new HttpRequestAdapter();
|
HttpRequestAdapter request =new HttpRequestAdapter();
|
||||||
String responseBody = request.get(String.format(TOKEN_URL, corpid,corpsecret));
|
String responseBody = request.get(String.format(TOKEN_URL, corpid,corpsecret));
|
||||||
|
|
||||||
AccessToken accessToken = JsonUtils.gson2Object(responseBody, AccessToken.class);
|
AccessToken accessToken = JsonUtils.gsonStringToObject(responseBody, AccessToken.class);
|
||||||
_logger.debug("accessToken " + accessToken);
|
_logger.debug("accessToken " + accessToken);
|
||||||
if(accessToken.getErrcode()== 0){
|
if(accessToken.getErrcode()== 0){
|
||||||
return accessToken.getAccess_token();
|
return accessToken.getAccess_token();
|
||||||
|
|||||||
@ -100,7 +100,7 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
|
|||||||
public WorkWeixinDeptsResponse requestDepartmentList(String access_token) {
|
public WorkWeixinDeptsResponse requestDepartmentList(String access_token) {
|
||||||
HttpRequestAdapter request =new HttpRequestAdapter();
|
HttpRequestAdapter request =new HttpRequestAdapter();
|
||||||
String responseBody = request.get(String.format(DEPTS_URL, access_token));
|
String responseBody = request.get(String.format(DEPTS_URL, access_token));
|
||||||
WorkWeixinDeptsResponse deptsResponse =JsonUtils.gson2Object(responseBody, WorkWeixinDeptsResponse.class);
|
WorkWeixinDeptsResponse deptsResponse =JsonUtils.gsonStringToObject(responseBody, WorkWeixinDeptsResponse.class);
|
||||||
|
|
||||||
_logger.trace("response : " + responseBody);
|
_logger.trace("response : " + responseBody);
|
||||||
for(WorkWeixinDepts dept : deptsResponse.getDepartment()) {
|
for(WorkWeixinDepts dept : deptsResponse.getDepartment()) {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
|
|||||||
for(SynchroRelated relatedOrg : synchroRelateds) {
|
for(SynchroRelated relatedOrg : synchroRelateds) {
|
||||||
HttpRequestAdapter request =new HttpRequestAdapter();
|
HttpRequestAdapter request =new HttpRequestAdapter();
|
||||||
String responseBody = request.get(String.format(USERS_URL, access_token,relatedOrg.getOriginId()));
|
String responseBody = request.get(String.format(USERS_URL, access_token,relatedOrg.getOriginId()));
|
||||||
WorkWeixinUsersResponse usersResponse =JsonUtils.gson2Object(responseBody, WorkWeixinUsersResponse.class);
|
WorkWeixinUsersResponse usersResponse =JsonUtils.gsonStringToObject(responseBody, WorkWeixinUsersResponse.class);
|
||||||
_logger.trace("response : " + responseBody);
|
_logger.trace("response : " + responseBody);
|
||||||
|
|
||||||
for(WorkWeixinUsers user : usersResponse.getUserlist()) {
|
for(WorkWeixinUsers user : usersResponse.getUserlist()) {
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public class KerberosPrincipal {
|
|||||||
System.out.println(DateUtils.toUtc(datetime));
|
System.out.println(DateUtils.toUtc(datetime));
|
||||||
String json="{\"fullPrincipal\":\"Administrator@CONNSEC.COM\",\"principal\":\"Administrator\",\"userDomain\":\"CONNSEC\",\"notOnOrAfter\":\"2014-01-18T07:10:16.624Z\"}";
|
String json="{\"fullPrincipal\":\"Administrator@CONNSEC.COM\",\"principal\":\"Administrator\",\"userDomain\":\"CONNSEC\",\"notOnOrAfter\":\"2014-01-18T07:10:16.624Z\"}";
|
||||||
KerberosToken kerberosToken=new KerberosToken();
|
KerberosToken kerberosToken=new KerberosToken();
|
||||||
kerberosToken=(KerberosToken)JsonUtils.json2Object(json, kerberosToken);
|
kerberosToken=(KerberosToken)JsonUtils.stringToObject(json, kerberosToken);
|
||||||
|
|
||||||
System.out.println(kerberosToken);
|
System.out.println(kerberosToken);
|
||||||
|
|
||||||
|
|||||||
@ -208,7 +208,7 @@ public class UserInfoController {
|
|||||||
for(int i=0;i<extraAttributeLabel.length;i++){
|
for(int i=0;i<extraAttributeLabel.length;i++){
|
||||||
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
|
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
|
||||||
}
|
}
|
||||||
String extraAttribute=JsonUtils.object2Json(extraAttributeMap);
|
String extraAttribute=JsonUtils.toString(extraAttributeMap);
|
||||||
userInfo.setExtraAttribute(extraAttribute);
|
userInfo.setExtraAttribute(extraAttribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user