当前位置: 首页>>代码示例>>Java>>正文


Java OAuth.newList方法代码示例

本文整理汇总了Java中net.oauth.OAuth.newList方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth.newList方法的具体用法?Java OAuth.newList怎么用?Java OAuth.newList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.oauth.OAuth的用法示例。


在下文中一共展示了OAuth.newList方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
    * Get an access token from the service provider, in exchange for an
    * authorized request token.
    * 
    * @param accessor
    *            should contain a non-null requestToken and tokenSecret, and a
    *            consumer that contains a consumerKey and consumerSecret. Also,
    *            accessor.consumer.serviceProvider.accessTokenURL should be the
    *            URL (determined by the service provider) for getting an access
    *            token.
    * @param httpMethod
    *            typically OAuthMessage.POST or OAuthMessage.GET, or null to
    *            use the default method.
    * @param parameters
    *            additional parameters for this request, or null to indicate
    *            that there are no additional parameters.
    * @throws OAuthProblemException
    *             the HTTP response status code was not 200 (OK)
    */
   @SuppressWarnings("rawtypes")
public OAuthMessage getAccessToken(OAuthAccessor accessor, String httpMethod,
           Collection<? extends Map.Entry> parameters) throws IOException, OAuthException, URISyntaxException {
       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);
               p.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN, accessor.requestToken));
               parameters = p;
           }
       }
       OAuthMessage response = invoke(accessor, httpMethod,
               accessor.consumer.serviceProvider.accessTokenURL, parameters);
       response.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
       accessor.accessToken = response.getParameter(OAuth.OAUTH_TOKEN);
       accessor.tokenSecret = response.getParameter(OAuth.OAUTH_TOKEN_SECRET);
       return response;
   }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:39,代码来源:OAuthClient.java

示例2: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Get an access token from the service provider, in exchange for an
 * authorized request token.
 * 
 * @param accessor
 *            should contain a non-null requestToken and tokenSecret, and a
 *            consumer that contains a consumerKey and consumerSecret. Also,
 *            accessor.consumer.serviceProvider.accessTokenURL should be the
 *            URL (determined by the service provider) for getting an access
 *            token.
 * @param httpMethod
 *            typically OAuthMessage.POST or OAuthMessage.GET, or null to
 *            use the default method.
 * @param parameters
 *            additional parameters for this request, or null to indicate
 *            that there are no additional parameters.
 * @return the response from the service provider
 * @throws OAuthProblemException
 *             the HTTP response status code was not 200 (OK)
 */
@SuppressWarnings("rawtypes")
public OAuthMessage getAccessToken(OAuthAccessor accessor,
		String httpMethod, Collection<? extends Map.Entry> parameters)
		throws IOException, OAuthException, URISyntaxException {
	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);
			p.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN,
					accessor.requestToken));
			parameters = p;
		}
	}
	OAuthMessage response = invoke(accessor, httpMethod,
			accessor.consumer.serviceProvider.accessTokenURL, parameters);
	response.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
	accessor.accessToken = response.getParameter(OAuth.OAUTH_TOKEN);
	accessor.tokenSecret = response.getParameter(OAuth.OAUTH_TOKEN_SECRET);
	return response;
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:43,代码来源:OAuthClient.java

示例3: testRedirect

import net.oauth.OAuth; //导入方法依赖的package包/类
public void testRedirect() throws Exception {
    final OAuthMessage request = new OAuthMessage("GET",
            "http://google.com/search", OAuth.newList("q", "Java"));
    final Integer expectedStatus = Integer.valueOf(301);
    final String expectedLocation = "http://www.google.com/search?q=Java";
    for (OAuthClient client : clients) {
        try {
            OAuthMessage response = client.invoke(request, ParameterStyle.BODY);
            fail(client.getHttpClient() + " response: " + response);
        } catch (OAuthProblemException e) {
            Map<String, Object> parameters = e.getParameters();
            assertEquals("status", expectedStatus, parameters.get(HttpMessage.STATUS_CODE));
            assertEquals("Location", expectedLocation, parameters.get(HttpResponseMessage.LOCATION));
        }
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:17,代码来源:OAuthClientTest.java

示例4: testAccess

import net.oauth.OAuth; //导入方法依赖的package包/类
public void testAccess() throws Exception {
    final String echo = "http://localhost:" + port + "/Echo";
    final List<OAuth.Parameter> parameters = OAuth.newList("n", "v");
    final String contentType = "text/fred; charset=" + OAuth.ENCODING;
    final byte[] content = "1234".getBytes(OAuth.ENCODING);
    for (OAuthClient client : clients) {
        String id = client.getHttpClient().toString();
        OAuthMessage request = new OAuthMessage(OAuthMessage.POST, echo, parameters, new ByteArrayInputStream(content));
        request.getHeaders().add(new OAuth.Parameter("Content-Type", contentType));
        OAuthMessage response = client.access(request, ParameterStyle.QUERY_STRING);
        String expectedBody = (client.getHttpClient() instanceof HttpClient4) //
                ? "POST\nn=v\nnull\n1234" // no Content-Length
                : "POST\nn=v\n4\n1234";
        String body = response.readBodyAsString();
        assertEquals(id, contentType, response.getHeader(HttpMessage.CONTENT_TYPE));
        assertEquals(id, expectedBody, body);
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:19,代码来源:OAuthClientTest.java

示例5: createRequestToken

import net.oauth.OAuth; //导入方法依赖的package包/类
private void createRequestToken(ContextResource contextResource) throws IOException, OAuthException, URISyntaxException {
    OAuthMessage requestMessage = getOAuthMessage(contextResource.getRequest());

    String consumerKey = requestMessage.getConsumerKey();
    if (consumerKey == null) {
        OAuthProblemException e = new OAuthProblemException(OAuth.Problems.PARAMETER_ABSENT);
        e.setParameter(OAuth.Problems.OAUTH_PARAMETERS_ABSENT, OAuth.OAUTH_CONSUMER_KEY);
        throw e;
    }
    OAuthConsumer consumer = dataStore.getConsumer(consumerKey);

    if (consumer == null) {
        throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
    }

    OAuthAccessor accessor = new OAuthAccessor(consumer);
    VALIDATOR.validateMessage(requestMessage, accessor);

    String callback = requestMessage.getParameter(OAuth.OAUTH_CALLBACK);

    if (callback == null) {
        // see if the consumer has a callback
        callback = consumer.callbackURL;
    }
    if (callback == null) {
        callback = "oob";
    }

    // generate request_token and secret
    OAuthEntry entry = dataStore.generateRequestToken(consumerKey, 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) {
        responseParams.add(new Parameter(OAuth.OAUTH_CALLBACK_CONFIRMED, "true"));
    }
    sendResponse(contextResource, responseParams);
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:38,代码来源:OAuthResource.java

示例6: invoke

import net.oauth.OAuth; //导入方法依赖的package包/类
private byte[] invoke(Method method, String identifier, List<OAuth.Parameter> params, HttpClient4 httpClient) {
	try {
		OAuthClient oAuthClient = new OAuthClient(httpClient);
		String url = BASE + getRootElementName() + "/";
		if (identifier != null) url = url + identifier;
		if (params == null) params = OAuth.newList();
		log.trace("Invoking : " + method + " on " + url);
		log.trace("--------------------------------");
		for (OAuth.Parameter param : params) {
			log.trace(param.getKey() + " : " + param.getValue());
		}
		log.trace("--------------------------------");
		OAuthMessage message = oAuthClient.invoke(xeroClient.getOAuthAccessor(), method.toString(), url, params);
		InputStream in = message.getBodyAsStream();
		byte[] build = IOUtils.toByteArray(in);
		in.close();
		return build;
	}
	catch (URISyntaxException urise) {
		throw new RuntimeException("Should not happen?", urise);
	}
	catch (IOException ioe) {
		throw new RuntimeException("Something went wrong connecting to the service.", ioe);
	}
	catch (OAuthException oae) {
		//oae.printStackTrace();
		throw new RuntimeException("Something went wrong with the OAuth connection.", oae);
	}
}
 
开发者ID:YouCanBookMe,项目名称:jXero,代码行数:30,代码来源:Endpoint.java

示例7: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Get a fresh access token from the service provider.
 * @throws IOException 
 * @throws URISyntaxException 
 * 
 * @throws RedirectException
 *             to obtain authorization
 */
private static void getAccessToken(HttpServletRequest request,
        CookieMap cookies, OAuthAccessor accessor)
    throws OAuthException, IOException, URISyntaxException
{
    final String consumerName = (String) accessor.consumer.getProperty("name");
    final String callbackURL = getCallbackURL(request, consumerName);
    List<OAuth.Parameter> parameters = OAuth.newList(OAuth.OAUTH_CALLBACK, callbackURL);
    // Google needs to know what you intend to do with the access token:
    Object scope = accessor.consumer.getProperty("request.scope");
    if (scope != null) {
        parameters.add(new OAuth.Parameter("scope", scope.toString()));
    }
    OAuthMessage response = CLIENT.getRequestTokenResponse(accessor, null, parameters);
    cookies.put(consumerName + ".requestToken", accessor.requestToken);
    cookies.put(consumerName + ".tokenSecret", accessor.tokenSecret);
    String authorizationURL = accessor.consumer.serviceProvider.userAuthorizationURL;
    if (authorizationURL.startsWith("/")) {
        authorizationURL = (new URL(new URL(request.getRequestURL()
                .toString()), request.getContextPath() + authorizationURL))
                .toString();
    }
    authorizationURL = OAuth.addParameters(authorizationURL //
            , OAuth.OAUTH_TOKEN, accessor.requestToken);
    if (response.getParameter(OAuth.OAUTH_CALLBACK_CONFIRMED) == null) {
        authorizationURL = OAuth.addParameters(authorizationURL //
                , OAuth.OAUTH_CALLBACK, callbackURL);
    }
    throw new RedirectException(authorizationURL);
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:38,代码来源:CookieConsumer.java

示例8: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Get an access token from the service provider, in exchange for an
 * authorized request token.
 * 
 * @param accessor
 *            should contain a non-null requestToken and tokenSecret, and a
 *            consumer that contains a consumerKey and consumerSecret. Also,
 *            accessor.consumer.serviceProvider.accessTokenURL should be the
 *            URL (determined by the service provider) for getting an access
 *            token.
 * @param httpMethod
 *            typically OAuthMessage.POST or OAuthMessage.GET, or null to
 *            use the default method.
 * @param parameters
 *            additional parameters for this request, or null to indicate
 *            that there are no additional parameters.
 * @throws OAuthProblemException
 *             the HTTP response status code was not 200 (OK)
 */
public OAuthMessage getAccessToken(OAuthAccessor accessor, String httpMethod,
        Collection<? extends Map.Entry> parameters) throws IOException, OAuthException, URISyntaxException {
    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);
            p.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN, accessor.requestToken));
            parameters = p;
        }
    }
    OAuthMessage response = invoke(accessor, httpMethod,
            accessor.consumer.serviceProvider.accessTokenURL, parameters);
    response.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
    accessor.accessToken = response.getParameter(OAuth.OAUTH_TOKEN);
    accessor.tokenSecret = response.getParameter(OAuth.OAUTH_TOKEN_SECRET);
    return response;
}
 
开发者ID:lshain-android-source,项目名称:external-oauth,代码行数:38,代码来源:OAuthClient.java

示例9: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Get an access token from the service provider, in exchange for an
 * authorized request token.
 * 
 * @param accessor
 *            should contain a non-null requestToken and tokenSecret, and a
 *            consumer that contains a consumerKey and consumerSecret. Also,
 *            accessor.consumer.serviceProvider.accessTokenURL should be the
 *            URL (determined by the service provider) for getting an access
 *            token.
 * @param httpMethod
 *            typically OAuthMessage.POST or OAuthMessage.GET, or null to
 *            use the default method.
 * @param parameters
 *            additional parameters for this request, or null to indicate
 *            that there are no additional parameters.
 * @return the response from the service provider
 * @throws OAuthProblemException
 *             the HTTP response status code was not 200 (OK)
 */
public OAuthMessage getAccessToken(OAuthAccessor accessor, String httpMethod,
        Collection<? extends Map.Entry> parameters) throws IOException, OAuthException, URISyntaxException {
    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);
            p.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN, accessor.requestToken));
            parameters = p;
        }
    }
    OAuthMessage response = invoke(accessor, httpMethod,
            accessor.consumer.serviceProvider.accessTokenURL, parameters);
    response.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
    accessor.accessToken = response.getParameter(OAuth.OAUTH_TOKEN);
    accessor.tokenSecret = response.getParameter(OAuth.OAUTH_TOKEN_SECRET);
    return response;
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:39,代码来源:OAuthClient.java

示例10: testInvokeMessage

import net.oauth.OAuth; //导入方法依赖的package包/类
public void testInvokeMessage() throws Exception {
    final String echo = "http://localhost:" + port + "/Echo";
    final String data = new String(new char[] { 0, 1, ' ', 'a', 127, 128,
            0xFF, 0x3000, 0x4E00 });
    final byte[] utf8 = data.getBytes("UTF-8");
    List<OAuth.Parameter> parameters = OAuth.newList("x", "y",
            "oauth_token", "t");
    String parametersForm = "oauth_token=t&x=y";
    final Object[][] messages = new Object[][] {
            { new OAuthMessage("GET", echo, parameters),
                    "GET\n" + parametersForm + "\n" + "null\n", null },
            {
                    new OAuthMessage("POST", echo, parameters),
                    "POST\n" + parametersForm + "\n"
                            + parametersForm.length() + "\n",
                    OAuth.FORM_ENCODED },
            {
                    new MessageWithBody("PUT", echo, parameters,
                            "text/OAuthClientTest; charset=\"UTF-8\"", utf8),
                    "PUT\n" + parametersForm + "\n"
                            + utf8.length + "\n" + data,
                    "text/OAuthClientTest; charset=UTF-8" },
            {
                    new MessageWithBody("PUT", echo, parameters,
                            "application/octet-stream", utf8),
                    "PUT\n" + parametersForm + "\n"
                            + utf8.length + "\n"
                            + new String(utf8, "ISO-8859-1"),
                    "application/octet-stream" },
            { new OAuthMessage("DELETE", echo, parameters),
                    "DELETE\n" + parametersForm + "\n" + "null\n", null } };
    final ParameterStyle[] styles = new ParameterStyle[] {
            ParameterStyle.BODY, ParameterStyle.AUTHORIZATION_HEADER };
    final long startTime = System.nanoTime();
    for (OAuthClient client : clients) {
        for (Object[] testCase : messages) {
            for (ParameterStyle style : styles) {
                OAuthMessage request = (OAuthMessage) testCase[0];
                final String id = client + " " + request.method + " " + style;
                OAuthMessage response = null;
                // System.out.println(id + " ...");
                try {
                    response = client.invoke(request, style);
                } catch (Exception e) {
                    AssertionError failure = new AssertionError(id);
                    failure.initCause(e);
                    throw failure;
                }
                // System.out.println(response.getDump()
                // .get(OAuthMessage.HTTP_REQUEST));
                String expectedBody = (String) testCase[1];
                if ("POST".equalsIgnoreCase(request.method)
                        && style == ParameterStyle.AUTHORIZATION_HEADER) {
                    // Only the non-oauth parameters went in the body.
                    expectedBody = expectedBody.replace("\n" + parametersForm.length()
                            + "\n", "\n3\n");
                }
                String body = response.readBodyAsString();
                assertEquals(id, expectedBody, body);
                assertEquals(id, testCase[2], response.getHeader(HttpMessage.CONTENT_TYPE));
            }
        }
    }
    final long endTime = System.nanoTime();
    final float elapsedSec = ((float) (endTime - startTime)) / 1000000000L;
    if (elapsedSec > 10) {
        fail("elapsed time = " + elapsedSec + " sec");
        // This often means the client isn't re-using TCP connections,
        // and consequently all the Jetty server threads are occupied
        // waiting for data on the wasted connections.
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:73,代码来源:OAuthClientTest.java

示例11: handleRequestTokenUrl

import net.oauth.OAuth; //导入方法依赖的package包/类
private HttpResponse handleRequestTokenUrl(HttpRequest request)
    throws Exception {
  MessageInfo info = parseMessage(request);
  String requestConsumer = info.message.getParameter(OAuth.OAUTH_CONSUMER_KEY);
  OAuthConsumer consumer;
  if (CONSUMER_KEY.equals(requestConsumer)) {
    consumer = oauthConsumer;
  } else {
    return makeOAuthProblemReport(
        OAuthConstants.PROBLEM_CONSUMER_KEY_UNKNOWN, "invalid consumer: " + requestConsumer,
        HttpResponse.SC_FORBIDDEN);
  }
  if (throttled) {
    return makeOAuthProblemReport(
        OAuthConstants.PROBLEM_CONSUMER_KEY_REFUSED, "exceeded quota exhausted",
        HttpResponse.SC_FORBIDDEN);
  }
  if (unauthorized) {
    return makeOAuthProblemReport(
        OAuthConstants.PROBLEM_PERMISSION_DENIED, "user refused access",
        HttpResponse.SC_BAD_REQUEST);
  }
  if (rejectExtraParams) {
    String extra = hasExtraParams(info.message);
    if (extra != null) {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_REJECTED, extra,
          HttpResponse.SC_BAD_REQUEST);
    }
  }
  OAuthAccessor accessor = new OAuthAccessor(consumer);
  validateMessage(accessor, info, true);
  String requestToken = Crypto.getRandomString(16);
  String requestTokenSecret = Crypto.getRandomString(16);
  String callbackUrl = info.message.getParameter(OAuth.OAUTH_CALLBACK);
  tokenState.put(
      requestToken, new TokenState(requestTokenSecret, accessor.consumer, callbackUrl));
  List<Parameter> responseParams = OAuth.newList(
      "oauth_token", requestToken,
      "oauth_token_secret", requestTokenSecret);
  if (callbackUrl != null) {
    responseParams.add(new Parameter(OAuthConstants.OAUTH_CALLBACK_CONFIRMED, "true"));
  }
  return new HttpResponse(OAuth.formEncode(responseParams));
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:45,代码来源:FakeOAuthServiceProvider.java

示例12: handleAccessTokenUrl

import net.oauth.OAuth; //导入方法依赖的package包/类
private HttpResponse handleAccessTokenUrl(HttpRequest request)
    throws Exception {
  MessageInfo info = parseMessage(request);
  String requestToken = info.message.getParameter("oauth_token");
  TokenState state = tokenState.get(requestToken);
  if (throttled) {
    return makeOAuthProblemReport(OAuthConstants.PROBLEM_CONSUMER_KEY_REFUSED,
        "exceeded quota", HttpResponse.SC_FORBIDDEN);
  } else if (unauthorized) {
    return makeOAuthProblemReport(OAuthConstants.PROBLEM_PERMISSION_DENIED,
        "user refused access", HttpResponse.SC_UNAUTHORIZED);
  } else if (state == null) {
    return makeOAuthProblemReport(OAuthConstants.PROBLEM_TOKEN_REJECTED,
        "Unknown request token", HttpResponse.SC_UNAUTHORIZED);
  }   
  if (rejectExtraParams) {
    String extra = hasExtraParams(info.message);
    if (extra != null) {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_REJECTED,
          extra, HttpResponse.SC_BAD_REQUEST);
    }
  }

  OAuthAccessor accessor = new OAuthAccessor(oauthConsumer);
  accessor.requestToken = requestToken;
  accessor.tokenSecret = state.tokenSecret;
  validateMessage(accessor, info, true);

  if (state.getState() == State.APPROVED_UNCLAIMED) {
    String sentVerifier = info.message.getParameter("oauth_verifier");
    if (state.verifier != null && !state.verifier.equals(sentVerifier)) {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_BAD_VERIFIER, "wrong oauth verifier",
          HttpResponse.SC_UNAUTHORIZED);
    }
    state.claimToken();
  } else if (state.getState() == State.APPROVED) {
    // Verify can refresh
    String sentHandle = info.message.getParameter("oauth_session_handle");
    if (sentHandle == null) {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_ABSENT,
          "no oauth_session_handle", HttpResponse.SC_BAD_REQUEST);
    }
    if (!sentHandle.equals(state.sessionHandle)) {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_TOKEN_INVALID, "token not valid",
          HttpResponse.SC_UNAUTHORIZED);
    }
    state.renewToken();
  } else if (state.getState() == State.REVOKED){
    return makeOAuthProblemReport(OAuthConstants.PROBLEM_TOKEN_REVOKED,
        "Revoked access token can't be renewed", HttpResponse.SC_UNAUTHORIZED);
  } else {
    throw new Exception("Token in weird state " + state.getState());
  }

  String accessToken = Crypto.getRandomString(16);
  String accessTokenSecret = Crypto.getRandomString(16);
  state.tokenSecret = accessTokenSecret;
  tokenState.put(accessToken, state);
  tokenState.remove(requestToken);
  List<OAuth.Parameter> params = OAuth.newList(
      "oauth_token", accessToken,
      "oauth_token_secret", accessTokenSecret);
  if (sessionExtension) {
    params.add(new OAuth.Parameter("oauth_session_handle", state.sessionHandle));
    if (reportExpirationTimes) {
      params.add(new OAuth.Parameter("oauth_expires_in", "" + TOKEN_EXPIRATION_SECONDS));
    }
  }
  if (returnAccessTokenData) {
    params.add(new OAuth.Parameter("userid", "userid value"));
    params.add(new OAuth.Parameter("xoauth_stuff", "xoauth_stuff value"));
    params.add(new OAuth.Parameter("oauth_stuff", "oauth_stuff value"));
  }
  return new HttpResponse(OAuth.formEncode(params));
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:76,代码来源:FakeOAuthServiceProvider.java


注:本文中的net.oauth.OAuth.newList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。