net.oauth.OAuth.newList()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中net.oauth.OAuth.newList()方法的一些代码示例,展示了OAuth.newList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OAuth.newList()方法的具体详情如下:
包路径:net.oauth.OAuth
类名称:OAuth
方法名:newList

OAuth.newList介绍

[英]Construct a list of Parameters from name, value, name, value...
[中]根据名称、值、名称、值。。。

代码示例

代码示例来源:origin: sakaiproject/sakai

/**
 * Construct a URL like the given one, but with the given parameters added
 * to its query string.
 */
public static String addParameters(String url, String... parameters)
    throws IOException {
  return addParameters(url, newList(parameters));
}

代码示例来源:origin: net.oauth.core/oauth

/**
 * Construct a URL like the given one, but with the given parameters added
 * to its query string.
 */
public static String addParameters(String url, String... parameters)
    throws IOException {
  return addParameters(url, newList(parameters));
}

代码示例来源: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: apache/incubator-wave

OAuth.formEncode(OAuth.newList(
  OAuth.OAUTH_TOKEN, accessor.requestToken,
  OAuth.OAUTH_TOKEN_SECRET, accessor.tokenSecret,

代码示例来源:origin: sakaiproject/sakai

if (accessor.requestToken != null) {
  if (parameters == null) {
    parameters = OAuth.newList(OAuth.OAUTH_TOKEN, accessor.requestToken);
  } else if (!OAuth.newMap(parameters).containsKey(OAuth.OAUTH_TOKEN)) {
    List<Map.Entry> p = new ArrayList<Map.Entry>(parameters);

代码示例来源: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);
  }
}

代码示例来源:origin: apache/roller

public void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  try{
    OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
    
    OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
    OAuthAccessor accessor = omgr.getAccessor(requestMessage);
    omgr.getValidator().validateMessage(requestMessage, accessor);
    
    // make sure token is authorized
    if (!Boolean.TRUE.equals(accessor.getProperty("authorized"))) {
       OAuthProblemException problem = new OAuthProblemException("permission_denied");
      throw problem;
    }
    // generate access token and secret
    if (accessor.accessToken == null) {
      omgr.generateAccessToken(accessor);
      WebloggerFactory.getWeblogger().flush();
    }
    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){
    handleException(e, request, response, true);
  }
}

代码示例来源:origin: edu.uiuc.ncsa.security.delegation/ncsa-security-oauth-1.0a

@Override
public CBResponse processCallbackRequest(CBRequest CBRequest) {
  List<OAuth.Parameter> parameters = OAuth.newList(OAuth.OAUTH_TOKEN,
      CBRequest.getAuthorizationGrant().getToken(),
      OAuth.OAUTH_VERIFIER,

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-social-api

private void createAccessToken(HttpServletRequest servletRequest,
                HttpServletResponse servletResponse) throws ServletException, IOException, OAuthException, URISyntaxException {
 OAuthMessage requestMessage = OAuthServlet.getMessage(servletRequest, null);
 OAuthEntry entry = getValidatedEntry(requestMessage);
 if (entry == null)
  throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
 if (entry.getCallbackToken() != null) {
  // We're using the fixed protocol
  String clientCallbackToken = requestMessage.getParameter(OAuth.OAUTH_VERIFIER);
  if (!entry.getCallbackToken().equals(clientCallbackToken)) {
   dataStore.disableToken(entry);
   servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
   return;
  }
 } else if (!entry.isAuthorized()) {
  // Old protocol.  Catch consumers trying to convert a token to one that's not authorized
  dataStore.disableToken(entry);
  servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
  return;
 }
 // turn request token into access token
 OAuthEntry accessEntry = dataStore.convertToAccessToken(entry);
 sendResponse(servletResponse, OAuth.newList(
         OAuth.OAUTH_TOKEN, accessEntry.getToken(),
         OAuth.OAUTH_TOKEN_SECRET, accessEntry.getTokenSecret(),
         "user_id", entry.getUserId()));
}

代码示例来源:origin: org.apache.shindig/shindig-social-api

private void createAccessToken(HttpServletRequest servletRequest,
                HttpServletResponse servletResponse) throws ServletException, IOException, OAuthException, URISyntaxException {
 OAuthMessage requestMessage = OAuthServlet.getMessage(servletRequest, null);
 OAuthEntry entry = getValidatedEntry(requestMessage);
 if (entry == null)
  throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
 if (entry.getCallbackToken() != null) {
  // We're using the fixed protocol
  String clientCallbackToken = requestMessage.getParameter(OAuth.OAUTH_VERIFIER);
  if (!entry.getCallbackToken().equals(clientCallbackToken)) {
   dataStore.disableToken(entry);
   servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
   return;
  }
 } else if (!entry.isAuthorized()) {
  // Old protocol.  Catch consumers trying to convert a token to one that's not authorized
  dataStore.disableToken(entry);
  servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
  return;
 }
 // turn request token into access token
 OAuthEntry accessEntry = dataStore.convertToAccessToken(entry);
 sendResponse(servletResponse, OAuth.newList(
         OAuth.OAUTH_TOKEN, accessEntry.getToken(),
         OAuth.OAUTH_TOKEN_SECRET, accessEntry.getTokenSecret(),
         "user_id", entry.getUserId()));
}

代码示例来源:origin: com.lmco.shindig/shindig-social-api

private void createAccessToken(HttpServletRequest servletRequest,
                HttpServletResponse servletResponse) throws ServletException, IOException, OAuthException, URISyntaxException {
 OAuthMessage requestMessage = OAuthServlet.getMessage(servletRequest, null);
 OAuthEntry entry = getValidatedEntry(requestMessage);
 if (entry == null)
  throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
 if (entry.getCallbackToken() != null) {
  // We're using the fixed protocol
  String clientCallbackToken = requestMessage.getParameter(OAuth.OAUTH_VERIFIER);
  if (!entry.getCallbackToken().equals(clientCallbackToken)) {
   dataStore.disableToken(entry);
   servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
   return;
  }
 } else if (!entry.isAuthorized()) {
  // Old protocol.  Catch consumers trying to convert a token to one that's not authorized
  dataStore.disableToken(entry); 
  servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "This token is not authorized");
  return;
 }
 // turn request token into access token
 OAuthEntry accessEntry = dataStore.convertToAccessToken(entry);
 sendResponse(servletResponse, OAuth.newList(
         OAuth.OAUTH_TOKEN, accessEntry.getToken(),
         OAuth.OAUTH_TOKEN_SECRET, accessEntry.getTokenSecret(),
         "user_id", entry.getUserId()));
}

代码示例来源:origin: apache/roller

String token = accessor.requestToken != null
    ? accessor.requestToken: accessor.accessToken;
OAuth.formEncode(OAuth.newList(
    "oauth_token", token,
    "oauth_token_secret", accessor.tokenSecret), out);

代码示例来源:origin: com.atlassian.oauth/atlassian-oauth-service-provider-plugin

formEncode(newList(
    OAUTH_TOKEN, accessToken.getToken(),
    OAUTH_TOKEN_SECRET, accessToken.getTokenSecret(),

代码示例来源:origin: org.apache.shindig/shindig-social-api

requestMessage.getParameter(OAuth.OAUTH_VERSION), callback);
List<Parameter> responseParams = OAuth.newList(OAuth.OAUTH_TOKEN, entry.getToken(),
                        OAuth.OAUTH_TOKEN_SECRET, entry.getTokenSecret());
if (callback != null) {

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-social-api

requestMessage.getParameter(OAuth.OAUTH_VERSION), callback);
List<Parameter> responseParams = OAuth.newList(OAuth.OAUTH_TOKEN, entry.getToken(),
                        OAuth.OAUTH_TOKEN_SECRET, entry.getTokenSecret());
if (callback != null) {

代码示例来源:origin: com.lmco.shindig/shindig-social-api

requestMessage.getParameter(OAuth.OAUTH_VERSION), callback);
List<Parameter> responseParams = OAuth.newList(OAuth.OAUTH_TOKEN, entry.getToken(),
                        OAuth.OAUTH_TOKEN_SECRET, entry.getTokenSecret());
if (callback != null) {

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

tokenState.put(
  requestToken, new TokenState(requestTokenSecret, callbackUrl));
List<Parameter> responseParams = OAuth.newList(
  "oauth_token", requestToken,
  "oauth_token_secret", requestTokenSecret);

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

tokenState.put(
  requestToken, new TokenState(requestTokenSecret, callbackUrl));
List<Parameter> responseParams = OAuth.newList(
  "oauth_token", requestToken,
  "oauth_token_secret", requestTokenSecret);

相关文章