本文整理了Java中org.apache.oltu.oauth2.common.utils.JSONUtils
类的一些代码示例,展示了JSONUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONUtils
类的具体详情如下:
包路径:org.apache.oltu.oauth2.common.utils.JSONUtils
类名称:JSONUtils
暂无
代码示例来源:origin: apache/oltu
protected void setBody(String body) throws OAuthProblemException {
try {
this.body = body;
parameters = JSONUtils.parseJSON(body);
} catch (Throwable e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
"Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
}
}
代码示例来源:origin: org.apache.oltu.oauth2/org.apache.oltu.oauth2.common
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params)
throws OAuthSystemException {
String json = null;
try {
json = JSONUtils.buildJSON(params);
message.setBody(json);
return message;
} catch (Throwable e) {
throw new OAuthSystemException(e);
}
}
代码示例来源:origin: apache/oltu
public static Map<String, Object> parseJSON(String jsonBody) {
final Map<String, Object> params = new HashMap<String, Object>();
StringReader reader = new StringReader(jsonBody);
JsonReader jsonReader = Json.createReader(reader);
JsonStructure structure = jsonReader.read();
if (structure == null || structure instanceof JsonArray) {
throw new IllegalArgumentException(format("String '%s' is not a valid JSON object representation",
jsonBody));
}
JsonObject object = (JsonObject) structure;
for (Entry<String, JsonValue> entry : object.entrySet()) {
String key = entry.getKey();
if (key != null && !key.isEmpty()) {
JsonValue jsonValue = entry.getValue();
// guard from null values
if (jsonValue != null) {
Object value = toJavaObject(jsonValue);
params.put(key, value);
}
}
}
jsonReader.close();
return params;
}
代码示例来源:origin: apache/oltu
witeItem(generator, Array.get(value, i));
witeItem(generator, item);
代码示例来源:origin: apache/oltu
for (int i = 0; i < array.size(); i++) {
JsonValue current = array.get(i);
values[i] = toJavaObject(current);
代码示例来源:origin: org.apache.oltu.oauth2/org.apache.oltu.oauth2.client
protected void setBody(String body) throws OAuthProblemException {
try {
this.body = body;
parameters = JSONUtils.parseJSON(body);
} catch (Throwable e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
"Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
}
}
代码示例来源:origin: apache/oltu
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params)
throws OAuthSystemException {
String json = null;
try {
json = JSONUtils.buildJSON(params);
message.setBody(json);
return message;
} catch (Throwable e) {
throw new OAuthSystemException(e);
}
}
代码示例来源:origin: apache/oltu
protected void setBody(String body) throws OAuthProblemException {
try {
this.body = body;
parameters = JSONUtils.parseJSON(body);
} catch (Throwable e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
"Invalid response! Response body is not application/json encoded");
}
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.application.authenticator.social
private Map<String, Object> getUserInfoJson(String fbAuthUserInfoUrl, String userInfoFields, String token)
throws ApplicationAuthenticatorException {
String userInfoString = getUserInfoString(fbAuthUserInfoUrl, userInfoFields, token);
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_ID_TOKEN)) {
log.debug("UserInfoString : " + userInfoString);
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(userInfoString);
return jsonObject;
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.application.authenticator.facebook
private Map<String, Object> getUserInfoJson(String fbAuthUserInfoUrl, String userInfoFields, String token)
throws ApplicationAuthenticatorException {
String userInfoString = getUserInfoString(fbAuthUserInfoUrl, userInfoFields, token);
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_ID_TOKEN)) {
log.debug("UserInfoString : " + userInfoString);
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(userInfoString);
return jsonObject;
}
protected Map<String, Object> getUserInfoJson(String fbAuthUserInfoUrl, String userInfoFields, String token)
throws ApplicationAuthenticatorException {
String userInfoString = getUserInfoString(fbAuthUserInfoUrl, userInfoFields, token);
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_ID_TOKEN)) {
log.debug("UserInfoString : " + userInfoString);
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(userInfoString);
return jsonObject;
}
代码示例来源:origin: org.everit.authentication/org.everit.authentication.oauth2.ri
private void setParameters(final String contentType, final String body)
throws OAuthProblemException {
if (contentType.contains("application/json")) {
try {
parameters = JSONUtils.parseJSON(body);
} catch (Throwable e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
"Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
}
} else {
parameters = OAuthUtils.decodeForm(body);
}
}
代码示例来源:origin: miltonio/milton2
@Override
protected void setBody(String body) throws OAuthProblemException {
this.body = body.trim();
if (isJson()) {
try {
parameters = JSONUtils.parseJSON(body);
} catch (Throwable e) {
throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE, "Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
}
} else {
parameters = OAuthUtils.decodeForm(body);
}
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
Map<String, Object> profile = null;
profile = JSONUtils.parseJSON(jsonObject.entrySet().iterator().next().getValue().toString());
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.application.authenticator.social
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
Map<String, Object> profile = null;
profile = JSONUtils.parseJSON(jsonObject.entrySet().iterator().next().getValue().toString());
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.application.authenticator.oidc
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
protected String getToken(String tokenEndPoint, String clientId, String clientSecret,
String callbackurl, String code) throws ApplicationAuthenticatorException {
OAuthClientRequest tokenRequest = null;
String token = null;
try {
tokenRequest =
buidTokenRequest(tokenEndPoint, clientId, clientSecret, callbackurl,
code);
String tokenResponse = sendRequest(tokenRequest.getLocationUri());
Map<String, Object> jsonObject = JSONUtils.parseJSON(tokenResponse);
token = (String) jsonObject.get(FacebookAuthenticatorConstants.FB_ACCESS_TOKEN);
if (StringUtils.isEmpty(token)) {
throw new ApplicationAuthenticatorException("Could not receive a valid access token from FB");
}
} catch (MalformedURLException e) {
if (log.isDebugEnabled()) {
log.debug("URL : " + tokenRequest.getLocationUri());
}
throw new ApplicationAuthenticatorException(
"MalformedURLException while sending access token request.",
e);
} catch (IOException e) {
throw new ApplicationAuthenticatorException("IOException while sending access token request.", e);
}
return token;
}
代码示例来源:origin: miltonio/milton2
responseMap = JSONUtils.parseJSON(resourceResponseBody);
内容来源于网络,如有侵权,请联系作者删除!