本文整理匯總了Java中oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.setAdditionalParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java CommonsHttpOAuthConsumer.setAdditionalParameters方法的具體用法?Java CommonsHttpOAuthConsumer.setAdditionalParameters怎麽用?Java CommonsHttpOAuthConsumer.setAdditionalParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oauth.signpost.commonshttp.CommonsHttpOAuthConsumer
的用法示例。
在下文中一共展示了CommonsHttpOAuthConsumer.setAdditionalParameters方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sign
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //導入方法依賴的package包/類
@Override
public HttpRequest sign(HttpRequest request, String key, String secret) throws LtiSigningException {
CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
try {
String body = getRequestBody(request);
String bodyHash = new String(Base64.encodeBase64(md.digest(body.getBytes())));
HttpParameters params = new HttpParameters();
params.put("oauth_body_hash", URLEncoder.encode(bodyHash, "UTF-8"));
signer.setAdditionalParameters(params);
signer.sign(request);
} catch (OAuthMessageSignerException|OAuthExpectationFailedException|OAuthCommunicationException|IOException e) {
throw new LtiSigningException("Exception encountered while singing Lti request...", e);
}
return request;
}
示例2: buildReplaceResult
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //導入方法依賴的package包/類
public static HttpPost buildReplaceResult(String url, String key, String secret, String sourcedid, String score, String resultData, Boolean isUrl) throws IOException, OAuthException, GeneralSecurityException {
String dataXml = "";
if (resultData != null) {
String format = isUrl ? resultDataUrl : resultDataText;
dataXml = String.format(format, StringEscapeUtils.escapeXml(resultData));
}
//*LAMS* the following line was added by LAMS and also messageIdentifier was added to the line after it
String messageIdentifier = UUID.randomUUID().toString();
String xml = String.format(replaceResultMessage, messageIdentifier, StringEscapeUtils.escapeXml(sourcedid),
StringEscapeUtils.escapeXml(score), dataXml);
HttpParameters parameters = new HttpParameters();
String hash = getBodyHash(xml);
parameters.put("oauth_body_hash", URLEncoder.encode(hash, "UTF-8"));
CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
HttpPost request = new HttpPost(url);
request.setHeader("Content-Type", "application/xml");
request.setEntity(new StringEntity(xml, "UTF-8"));
signer.setAdditionalParameters(parameters);
signer.sign(request);
return request;
}
示例3: buildReplaceResult
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //導入方法依賴的package包/類
public static HttpPost buildReplaceResult(String url, String key, String secret, String sourcedid,
String score, String resultData, Boolean isUrl, String messageId) throws IOException, OAuthException, GeneralSecurityException
{
String dataXml = "";
if (resultData != null) {
String format = isUrl ? resultDataUrl : resultDataText;
dataXml = String.format(format, StringEscapeUtils.escapeXml(resultData));
}
String messageIdentifier = StringUtils.isBlank(messageId) ? String.valueOf(new Date().getTime()) : messageId;
String xml = String.format(ReplaceResultMessageTemplate,
StringEscapeUtils.escapeXml(messageIdentifier),
StringEscapeUtils.escapeXml(sourcedid),
StringEscapeUtils.escapeXml(score),
dataXml);
HttpParameters parameters = new HttpParameters();
String hash = getBodyHash(xml);
parameters.put("oauth_body_hash", URLEncoder.encode(hash, "UTF-8"));
CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
HttpPost request = new HttpPost(url);
request.setHeader("Content-Type", "application/xml");
request.setEntity(new StringEntity(xml, "UTF-8"));
signer.setAdditionalParameters(parameters);
signer.sign(request);
return request;
}