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


Java OAuth.addParameters方法代码示例

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


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

示例1: doGet

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Do a http get for the given url.
 *
 * @param url requested url
 * @param parameters request parameters
 * @param accessor oauth accessor
 * @return the http response
 * @throws IOException
 * @throws {@link YNoteException}
 */
public static HttpResponse doGet(String url, Map<String, String> parameters,
        OAuthAccessor accessor) throws IOException, YNoteException {
    // add ynote parameters to the url
    OAuth.addParameters(url, parameters == null ? null : parameters.entrySet());
    HttpGet get = new HttpGet(url);
    // sign all parameters, including oauth parameters and ynote parameters
    // and add the oauth related information into the header        
    Header oauthHeader = getAuthorizationHeader(url, OAuthMessage.GET,
            parameters, accessor);
    get.addHeader(oauthHeader);
    HttpParams params = new BasicHttpParams();
    HttpClientParams.setRedirecting(params, false);
    get.setParams(params);
    HttpResponse response = client.execute(get);
    if ((response.getStatusLine().getStatusCode() / 100) != 2) {
        YNoteException e = wrapYNoteException(response);
        throw e;
    }
    return response;
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:31,代码来源:YNoteHttpUtils.java

示例2: getOAuthURL

import net.oauth.OAuth; //导入方法依赖的package包/类
/** 
        * getOAuthURL - Form a GET request signed by OAuth
 * @param method
 * @param url
 * @param oauth_consumer_key
 * @param oauth_consumer_secret
 * @param signature
 */
public static String getOAuthURL(String method, String url, 
	String oauth_consumer_key, String oauth_secret, String signature)
{
	OAuthMessage om = new OAuthMessage(method, url, null);
	om.addParameter(OAuth.OAUTH_CONSUMER_KEY, oauth_consumer_key);
	if ( signature == null ) signature = OAuth.HMAC_SHA1;
	om.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, signature);
	om.addParameter(OAuth.OAUTH_VERSION, "1.0");
	om.addParameter(OAuth.OAUTH_TIMESTAMP, new Long((new Date().getTime()) / 1000).toString());
	om.addParameter(OAuth.OAUTH_NONCE, UUID.randomUUID().toString());

	OAuthConsumer oc = new OAuthConsumer(null, oauth_consumer_key, oauth_secret, null);
	try {
	    OAuthSignatureMethod osm = OAuthSignatureMethod.newMethod(signature, new OAuthAccessor(oc));
	    osm.sign(om);
	    url = OAuth.addParameters(url, om.getParameters());
	    return url;
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:31,代码来源:BasicLTIUtil.java

示例3: grantRequestToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Grant the OAuth request token and secret for this consumer based on the
 * consumer key and consumer secret.
 *
 * @return the user authorization URL
 * @throws YNoteException 
 * @throws IOException 
 */
public String grantRequestToken(String callbackURL) throws IOException,
        YNoteException {
    lock.writeLock().lock();
    try {
        HttpResponse response = YNoteHttpUtils.doGet(
                accessor.consumer.serviceProvider.requestTokenURL,
                null, accessor);
        // extract the request token and token secret
        String content = YNoteHttpUtils.getResponseContent(
                response.getEntity().getContent());
        Map<String, String> model = YNoteHttpUtils.parseOAuthResponse(content);
        accessor.requestToken = model.get(OAuth.OAUTH_TOKEN);
        accessor.tokenSecret = model.get(OAuth.OAUTH_TOKEN_SECRET);
        // compose the authorization url, add the callback url if exists
        String authorizationURL = OAuth.addParameters(
                accessor.consumer.serviceProvider.userAuthorizationURL,
                OAuth.OAUTH_TOKEN, accessor.requestToken);
        if (callbackURL == null || callbackURL.isEmpty()) {
            callbackURL = accessor.consumer.callbackURL;
        }
        if (callbackURL != null && !callbackURL.isEmpty()) {
            authorizationURL = OAuth.addParameters(authorizationURL,
                    OAuth.OAUTH_CALLBACK, callbackURL);
        }
        return authorizationURL;
    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:38,代码来源:YNoteClient.java

示例4: getRequestURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getRequestURL(String consumerKey, String consumerSecret) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", RequestURL, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 message.addParameter(OAuth.OAUTH_CALLBACK, consumer.callbackURL);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:9,代码来源:OAuthTest.java

示例5: getAccessURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getAccessURL(String consumerKey, String consumerSecret, String requestKey, String requestSecret, String verifier) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", AccessURL, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 accessor.requestToken = requestKey;
 accessor.tokenSecret = requestSecret;
 message.addParameter(OAuthUtils.OAUTH_VERIFIER_PARAM, verifier);
 message.addParameter(OAuth.OAUTH_TOKEN, requestKey);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:12,代码来源:OAuthTest.java

示例6: getProtectedURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getProtectedURL(String url, String consumerKey, String consumerSecret, String accessKey, String accessSecret) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", ProtectedURL+url, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 accessor.accessToken = accessKey;
 accessor.tokenSecret = accessSecret;
 message.addParameter(OAuth.OAUTH_TOKEN, accessKey);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:11,代码来源:OAuthTest.java

示例7: getPushMessageURL

import net.oauth.OAuth; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private String getPushMessageURL(String callbackURI, String messageSenderId) 
   throws Exception {
   OAuthMessage message = new OAuthMessage("POST", callbackURI, Collections.<Map.Entry>emptyList());
   OAuthConsumer consumer = new OAuthConsumer(null, messageSenderId, 
        getConsumerSecret(messageSenderId), null);
   OAuthAccessor accessor = new OAuthAccessor(consumer);
   message.addRequiredParameters(accessor);
   return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:11,代码来源:OAuthMessageSender.java

示例8: getRequestURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getRequestURL(String consumerKey, String consumerSecret, 
                             String callbackURI, String scope, String permission) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", RequestTokenURL, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer(callbackURI, consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 message.addParameter(OAuth.OAUTH_CALLBACK, consumer.callbackURL);
 message.addParameter("xoauth_scope", scope);
 message.addParameter("xoauth_permission", permission);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:12,代码来源:ConsumerResource.java

示例9: getAuthorizationURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getAuthorizationURL(String consumerKey, Token requestToken) throws Exception {
    List<OAuth.Parameter> parameters = new ArrayList<OAuth.Parameter>();
    //parameters.add(new OAuth.Parameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey));
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN, requestToken.getToken()));
    
    return OAuth.addParameters(TokenAuthorizationURL, parameters);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:8,代码来源:ConsumerResource.java

示例10: getAccessURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getAccessURL(String consumerKey, String consumerSecret, String requestKey, String requestSecret, String verifier) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", AccessTokenURL, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 accessor.requestToken = requestKey;
 accessor.tokenSecret = requestSecret;
 message.addParameter(OAuthUtils.OAUTH_VERIFIER_PARAM, verifier);
 message.addParameter(OAuth.OAUTH_TOKEN, requestKey);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:12,代码来源:ConsumerResource.java

示例11: getEndUserURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getEndUserURL(String url, String consumerKey, String consumerSecret, String accessKey, String accessSecret) throws Exception {
 OAuthMessage message = new OAuthMessage("GET", endUserScope + url, Collections.<Map.Entry>emptyList());
 OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
 OAuthAccessor accessor = new OAuthAccessor(consumer);
 accessor.accessToken = accessKey;
 accessor.tokenSecret = accessSecret;
 message.addParameter(OAuth.OAUTH_TOKEN, accessKey);
 message.addRequiredParameters(accessor);
 return OAuth.addParameters(message.URL, message.getParameters());
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:11,代码来源:ConsumerResource.java

示例12: 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

示例13: getCallbackURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private static String getCallbackURL(HttpServletRequest request, String consumerName)
    throws IOException
{
    URL base = new URL(new URL(request.getRequestURL().toString()), //
            request.getContextPath() + Callback.PATH);
    return OAuth.addParameters(base.toExternalForm() //
            , "consumer", consumerName //
            , "returnTo", getRequestPath(request) //
            );
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:11,代码来源:CookieConsumer.java

示例14: doGet

import net.oauth.OAuth; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    String callback = request.getParameter("oauth_callback");
    String token = request.getParameter("oauth_token");
    if (token != null) {
        callback = OAuth.addParameters(callback, "oauth_token", token);
    }
    response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
    response.setHeader("Location", callback);
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:12,代码来源:UserAuthorizationStub.java

示例15: returnToConsumer

import net.oauth.OAuth; //导入方法依赖的package包/类
private void returnToConsumer(HttpServletRequest request, 
        HttpServletResponse response, OAuthAccessor accessor)
throws IOException, ServletException{
    // send the user back to site's callBackUrl
    String callback = request.getParameter("oauth_callback");
    if("none".equals(callback) 
        && accessor.consumer.callbackURL != null 
            && accessor.consumer.callbackURL.length() > 0){
        // first check if we have something in our properties file
        callback = accessor.consumer.callbackURL;
    }
    
    if( "none".equals(callback) ) {
        // no call back it must be a client
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println("You have successfully authorized '" 
                + accessor.consumer.getProperty("description") 
                + "'. Please close this browser window and click continue"
                + " in the client.");
        out.close();
    } else {
        // if callback is not passed in, use the callback from config
        if(callback == null || callback.length() <=0 )
            callback = accessor.consumer.callbackURL;
        String token = accessor.requestToken;
        if (token != null) {
            callback = OAuth.addParameters(callback, "oauth_token", token);
        }

        response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
        response.setHeader("Location", callback);
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:35,代码来源:AuthorizationServlet.java


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