本文整理了Java中net.oauth.OAuth.formEncode()
方法的一些代码示例,展示了OAuth.formEncode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OAuth.formEncode()
方法的具体详情如下:
包路径:net.oauth.OAuth
类名称:OAuth
方法名:formEncode
[英]Construct a form-urlencoded document containing the given sequence of name/value pairs. Use OAuth percent encoding (not exactly the encoding mandated by HTTP).
[中]构造一个包含给定名称/值对序列的表单URL编码文档。使用OAuth百分比编码(不完全是HTTP要求的编码)。
代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common
public static String formEncode(Iterable<? extends Entry<String, String>> parameters) {
try {
return OAuth.formEncode(parameters);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.gatein.shindig/shindig-common
public static String formEncode(Iterable<? extends Entry<String, String>> parameters) {
try {
return OAuth.formEncode(parameters);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.lmco.shindig/shindig-common
public static String formEncode(Iterable<? extends Entry<String, String>> parameters) {
try {
return OAuth.formEncode(parameters);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.shindig/shindig-common
public static String formEncode(Iterable<? extends Entry<String, String>> parameters) {
try {
return OAuth.formEncode(parameters);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/shindig
public static String formEncode(Iterable<? extends Entry<String, String>> parameters) {
try {
return OAuth.formEncode(parameters);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: sakaiproject/sakai
public static String addParameters(String url,
Iterable<? extends Map.Entry<String, String>> parameters)
throws IOException {
String form = formEncode(parameters);
if (form == null || form.length() <= 0) {
return url;
} else {
return url + ((url.indexOf("?") < 0) ? '?' : '&') + form;
}
}
代码示例来源:origin: net.oauth.core/oauth
public static String addParameters(String url,
Iterable<? extends Map.Entry<String, String>> parameters)
throws IOException {
String form = formEncode(parameters);
if (form == null || form.length() <= 0) {
return url;
} else {
return url + ((url.indexOf("?") < 0) ? '?' : '&') + form;
}
}
代码示例来源:origin: sakaiproject/sakai
/**
* Construct a form-urlencoded document containing the given sequence of
* name/value pairs. Use OAuth percent encoding (not exactly the encoding
* mandated by HTTP).
*/
@SuppressWarnings("rawtypes")
public static String formEncode(Iterable<? extends Map.Entry> parameters)
throws IOException {
ByteArrayOutputStream b = new ByteArrayOutputStream();
formEncode(parameters, b);
return new String(b.toByteArray());
}
代码示例来源:origin: org.wso2.org.apache.shindig/shindig-social-api
private void sendResponse(HttpServletResponse servletResponse, List<OAuth.Parameter> parameters)
throws IOException {
servletResponse.setContentType("text/plain");
OutputStream out = servletResponse.getOutputStream();
OAuth.formEncode(parameters, out);
out.close();
}
代码示例来源:origin: com.lmco.shindig/shindig-social-api
private void sendResponse(HttpServletResponse servletResponse, List<OAuth.Parameter> parameters)
throws IOException {
servletResponse.setContentType("text/plain");
OutputStream out = servletResponse.getOutputStream();
OAuth.formEncode(parameters, out);
out.close();
}
代码示例来源:origin: org.apache.shindig/shindig-social-api
private void sendResponse(HttpServletResponse servletResponse, List<OAuth.Parameter> parameters)
throws IOException {
servletResponse.setContentType("text/plain");
OutputStream out = servletResponse.getOutputStream();
OAuth.formEncode(parameters, out);
out.close();
}
代码示例来源:origin: sakaiproject/sakai
/** Send the given parameters as a form-encoded response body. */
@SuppressWarnings("rawtypes")
public static void sendForm(HttpServletResponse response,
Iterable<? extends Map.Entry> parameters) throws IOException {
response.resetBuffer();
response.setContentType(OAuth.FORM_ENCODED + ";charset="
+ OAuth.ENCODING);
OAuth.formEncode(parameters, response.getOutputStream());
}
代码示例来源:origin: net.oauth.core/oauth
/**
* Construct a form-urlencoded document containing the given sequence of
* name/value pairs. Use OAuth percent encoding (not exactly the encoding
* mandated by HTTP).
*/
public static String formEncode(Iterable<? extends Map.Entry> parameters)
throws IOException {
ByteArrayOutputStream b = new ByteArrayOutputStream();
formEncode(parameters, b);
return decodeCharacters(b.toByteArray());
}
代码示例来源:origin: net.oauth.core/oauth
protected static String normalizeParameters(
Collection<? extends Map.Entry> parameters) throws IOException {
if (parameters == null) {
return "";
}
List<ComparableParameter> p = new ArrayList<ComparableParameter>(
parameters.size());
for (Map.Entry parameter : parameters) {
if (!"oauth_signature".equals(parameter.getKey())) {
p.add(new ComparableParameter(parameter));
}
}
Collections.sort(p);
return OAuth.formEncode(getParameters(p));
}
代码示例来源:origin: sakaiproject/sakai
@SuppressWarnings("rawtypes")
protected static String normalizeParameters(
Collection<? extends Map.Entry> parameters) throws IOException {
if (parameters == null) {
return "";
}
List<ComparableParameter> p = new ArrayList<ComparableParameter>(
parameters.size());
for (Map.Entry parameter : parameters) {
if (!"oauth_signature".equals(parameter.getKey())) {
p.add(new ComparableParameter(parameter));
}
}
Collections.sort(p);
return OAuth.formEncode(getParameters(p));
}
代码示例来源:origin: edu.uiuc.ncsa.security.delegation/ncsa-security-oauth-1.0a
public void write(HttpServletResponse response) throws IOException {
response.setContentType(OAuthConstants.FORM_ENCODING);
OutputStream out = response.getOutputStream();
List<OAuth.Parameter> list;
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(OAuth.OAUTH_TOKEN);
arrayList.add(getGrant().getToken());
arrayList.add(OAuth.OAUTH_TOKEN_SECRET);
arrayList.add(getGrant().getSharedSecret());
for (String k : getParameters().keySet()) {
if (!k.startsWith("oauth_")) {
arrayList.add(k);
arrayList.add(getParameters().get(k));
}
}
list = OAuth.newList(arrayList.toArray(new String[arrayList.size()]));
OAuth.formEncode(list, out);
out.flush();
out.close();
}
代码示例来源:origin: edu.uiuc.ncsa.security.delegation/ncsa-security-oauth-1.0a
public void write(HttpServletResponse response) {
response.setContentType(OAuthConstants.FORM_ENCODING);
try {
OutputStream out = response.getOutputStream();
List<OAuth.Parameter> list;
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(OAuth.OAUTH_TOKEN);
arrayList.add(getAccessToken().getToken());
arrayList.add(OAuth.OAUTH_TOKEN_SECRET);
arrayList.add(getAccessToken().getSharedSecret());
for (String k : getParameters().keySet()) {
if (!k.startsWith("oauth_")) {
arrayList.add(k);
arrayList.add(getParameters().get(k));
}
}
list = OAuth.newList(arrayList.toArray(new String[arrayList.size()]));
OAuth.formEncode(list, out);
out.flush();
out.close();
} catch (IOException e) {
throw new GeneralException("Error writing to output stream", e);
}
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-oauth-plugin
private void obtainAndAuthorizeRequestToken(final ApplicationLink applicationLink, final HttpServletResponse resp, final HttpServletRequest req)
throws ResponseException, IOException {
final Map<String, String> config = authenticationConfigurationManager.getConfiguration(applicationLink.getId(), OAuthAuthenticationProvider.class);
final ServiceProvider serviceProvider = ServiceProviderUtil.getServiceProvider(config, applicationLink);
final String consumerKey = getConsumerKey(applicationLink);
final String redirectUrl = getRedirectUrl(req);
URI baseUrl = RequestUtil.getBaseURLFromRequest(req, internalHostApplication.getBaseUrl());
final String redirectToMeUrl = baseUrl + ServletPathConstants.APPLINKS_SERVLETS_PATH + "/oauth/login-dance/" + ACCESS_PATH
+ "?" + APPLICATION_LINK_ID_PARAM + "=" + applicationLink.getId() + (redirectUrl != null ? "&" + REDIRECT_URL_PARAM + "=" + URLEncoder.encode(redirectUrl, "UTF-8") : "");
final ConsumerToken requestToken = oAuthTokenRetriever.getRequestToken(serviceProvider, consumerKey, redirectToMeUrl);
consumerTokenStoreService.addConsumerToken(applicationLink, getRemoteUsername(req), requestToken);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(OAuth.OAUTH_TOKEN, requestToken.getToken());
parameters.put(OAuth.OAUTH_CALLBACK, redirectToMeUrl);
resp.sendRedirect(serviceProvider.getAuthorizeUri() + "?" + OAuth.formEncode(parameters.entrySet()));
}
代码示例来源:origin: org.entando.entando/entando-core-engine
public void processRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
IOAuthConsumerManager consumerManager =
(IOAuthConsumerManager) ApsWebApplicationUtils.getBean(SystemConstants.OAUTH_CONSUMER_MANAGER, request);
try {
OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
OAuthAccessor accessor = consumerManager.getAccessor(requestMessage);
consumerManager.getOAuthValidator().validateMessage(requestMessage, accessor);
if (!Boolean.TRUE.equals(accessor.getProperty("authorized"))) {
OAuthProblemException problem = new OAuthProblemException("permission_denied");
throw problem;
}
consumerManager.generateAccessToken(accessor);
response.setContentType("text/plain");
OutputStream out = response.getOutputStream();
OAuth.formEncode(OAuth.newList("oauth_token", accessor.accessToken,
"oauth_token_secret", accessor.tokenSecret), out);
out.close();
} catch (Exception e) {
consumerManager.handleException(e, request, response, true);
}
}
代码示例来源:origin: org.entando.entando/entando-core-engine
public void processRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
IOAuthConsumerManager consumerManager =
(IOAuthConsumerManager) ApsWebApplicationUtils.getBean(SystemConstants.OAUTH_CONSUMER_MANAGER, request);
try {
OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
OAuthConsumer consumer = consumerManager.getConsumer(requestMessage);
OAuthAccessor accessor = new OAuthAccessor(consumer);
consumerManager.getOAuthValidator().validateMessage(requestMessage, accessor);
String secret = requestMessage.getParameter("oauth_accessor_secret");
if (secret != null) {
accessor.setProperty(OAuthConsumer.ACCESSOR_SECRET, secret);
}
consumerManager.generateRequestToken(accessor);
response.setContentType("text/plain");
OutputStream out = response.getOutputStream();
OAuth.formEncode(OAuth.newList("oauth_token", accessor.requestToken,
"oauth_token_secret", accessor.tokenSecret), out);
out.close();
} catch (Exception e){
consumerManager.handleException(e, request, response, true);
}
}
内容来源于网络,如有侵权,请联系作者删除!