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


Java DefaultOAuthConsumer类代码示例

本文整理汇总了Java中oauth.signpost.basic.DefaultOAuthConsumer的典型用法代码示例。如果您正苦于以下问题:Java DefaultOAuthConsumer类的具体用法?Java DefaultOAuthConsumer怎么用?Java DefaultOAuthConsumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createOAuthConsumer

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private OAuthConsumer createOAuthConsumer() throws OAuthExpectationFailedException
{
	synchronized(oauthLock)
	{
		if(oauth == null)
		{
			throw new OAuthExpectationFailedException(
					"This class has been initialized without a OAuthConsumer. Only API calls " +
					"that do not require authentication can be made.");
		}

		// "clone" the original consumer every time because the consumer is documented to be not
		// thread safe and maybe multiple threads are making calls to this class
		OAuthConsumer consumer = new DefaultOAuthConsumer(
				oauth.getConsumerKey(), oauth.getConsumerSecret());
		consumer.setTokenWithSecret(oauth.getToken(), oauth.getTokenSecret());
		return consumer;
	}
}
 
开发者ID:westnordost,项目名称:osmapi,代码行数:20,代码来源:OsmConnection.java

示例2: OAuthConnector

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
public OAuthConnector(OAuthServer server) {
    logger.entry(server);
    if (server == null) {
        throw new IllegalArgumentException("Server must not be null.");
    }

    logger.debug("new OAuthconn");

    this.mServer = server;
    this.mConsumer = new DefaultOAuthConsumer(server.getConsumerKey(), server.getConsumerSecret());

    String accessToken = mServer.getAccessToken();
    String accessTokenSecret = mServer.getAccessTokenSecret();

    if (accessToken != null || accessTokenSecret != null) {
        this.mConsumer.setTokenWithSecret(accessToken, accessTokenSecret);
        isAuthorized = true;
    }
    logger.exit(server);
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:21,代码来源:OAuthConnector.java

示例3: getOAuthUri

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private static final String getOAuthUri(String uri, List<NameValuePair> params, String key, String secret) {
    final OAuthConsumer consumer = new DefaultOAuthConsumer(key, secret);

    HttpParameters additionalParameters = new HttpParameters();
    additionalParameters.put("oauth_timestamp", String.valueOf(getDate().getTime() / 1000));
    consumer.setAdditionalParameters(additionalParameters);
    try {
        return consumer.sign(uri + "?" + URLEncodedUtils.format(params, "UTF-8"));
    } catch (OAuthException e) {
        try {
            return uri + "web/error.html?message=" + URLEncoder.encode(e.getMessage(), "UTF-8");
        } catch (UnsupportedEncodingException f) {
            return uri + "web/error.html?message=Unknown%20Error";
        }
    }
}
 
开发者ID:toopher,项目名称:toopher-pingfederate,代码行数:17,代码来源:ToopherIframe.java

示例4: processHttpMessage

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)
{
	if (messageIsRequest && shouldSign(messageInfo))
	{
		HttpRequest req = new BurpHttpRequestWrapper(messageInfo);
		OAuthConsumer consumer = new DefaultOAuthConsumer(
				OAuthConfig.getConsumerKey(),
				OAuthConfig.getConsumerSecret());
		consumer.setTokenWithSecret(OAuthConfig.getToken(),
				OAuthConfig.getTokenSecret());
		try {
			consumer.sign(req);
		} catch (OAuthException oae) {
			oae.printStackTrace();
		}
	}
}
 
开发者ID:dnet,项目名称:burp-oauth,代码行数:19,代码来源:BurpExtender.java

示例5: createOAuthConsumer

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
public static OAuthConsumer createOAuthConsumer(OAuthConsumer oauth) throws OAuthExpectationFailedException {
    if (oauth == null) {
        throw new OAuthExpectationFailedException(
                "This class has been initialized without a OAuthConsumer. Only API calls " +
                        "that do not require authentication can be made.");
    }

    // "clone" the original consumer every time because the consumer is documented to be not
    // thread safe and maybe multiple threads are making calls to this class
    OAuthConsumer consumer = new DefaultOAuthConsumer(
            oauth.getConsumerKey(), oauth.getConsumerSecret());
    consumer.setTokenWithSecret(oauth.getToken(), oauth.getTokenSecret());
    return consumer;
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:15,代码来源:Authenticator.java

示例6: makeRequest

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
/**
 * Makes a one-legged OAuth 1.0a request for the specified URL.
 *
 * @param url the URL being requested
 * @return an HttpResponse
 * @since 1.0.0
 */
private HttpResponse<JsonNode> makeRequest(String url) {
    try {
        final OAuthConsumer consumer = new DefaultOAuthConsumer(this.consumerKey, this.consumerSecret);
        final String signed = consumer.sign(url);
        return Unirest.get(signed).header("X-User-Agent", USER_AGENT).asJson();
    } catch (OAuthException | UnirestException e) {
        LOGGER.error("An error occurred making request: " + url, e);
    }
    return null;
}
 
开发者ID:stevespringett,项目名称:vulndb-data-mirror,代码行数:18,代码来源:VulnDbApi.java

示例7: retrieveRequestToken

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
/**
 * Request the request token and secret.
 *
 * @param callbackURL the URL where the provider should redirect to (usually a URL on the current app)
 * @return A Right(RequestToken) in case of success, Left(OAuthException) otherwise
 */
public RequestToken retrieveRequestToken(String callbackURL) {
    OAuthConsumer consumer = new DefaultOAuthConsumer(info.key.key, info.key.secret);
    try {
        provider.retrieveRequestToken(consumer, callbackURL);
        return new RequestToken(consumer.getToken(), consumer.getTokenSecret());
    } catch(OAuthException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:16,代码来源:OAuth.java

示例8: retrieveAccessToken

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
/**
 * Exchange a request token for an access token.
 *
 * @param token the token/secret pair obtained from a previous call
 * @param verifier a string you got through your user, with redirection
 * @return A Right(RequestToken) in case of success, Left(OAuthException) otherwise
 */
public RequestToken retrieveAccessToken(RequestToken token, String verifier) {
    OAuthConsumer consumer = new DefaultOAuthConsumer(info.key.key, info.key.secret);
    consumer.setTokenWithSecret(token.token, token.secret);
    try {
        provider.retrieveAccessToken(consumer, verifier);
        return new RequestToken(consumer.getToken(), consumer.getTokenSecret());
    } catch (OAuthException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:18,代码来源:OAuth.java

示例9: createConsumerThatProhibitsEverything

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private static OAuthConsumer createConsumerThatProhibitsEverything()
{
	OAuthConsumer result = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
	result.setTokenWithSecret(
			"RCamNf4TT7uNeFjmigvOUWhajp5ERFZmcN1qvi7a",
			"72dzmAvuNBEOVKkif3JSYdzMlAq2dw5OnIG75dtX");
	return result;
}
 
开发者ID:westnordost,项目名称:osmapi,代码行数:9,代码来源:ConnectionTestFactory.java

示例10: createConsumerThatAllowsEverything

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private static OAuthConsumer createConsumerThatAllowsEverything()
{
	OAuthConsumer result = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
	result.setTokenWithSecret(
			"2C4LiOQBOn96kXHyal7uzMJiqpCsiyDBvb8pomyX",
			"1bFMIQpgmu5yjywt3kknopQpcRmwJ6snDDGF7kdr");
	return result;
}
 
开发者ID:westnordost,项目名称:osmapi,代码行数:9,代码来源:ConnectionTestFactory.java

示例11: createOAuthConsumer

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private OAuthConsumer createOAuthConsumer() {
    final OAuthConsumer consumer = new DefaultOAuthConsumer(client.getKey(), client.getSecret());
    if (null != token) {
        consumer.setTokenWithSecret(token.getToken(), token.getSecret());
    }
    return consumer;
}
 
开发者ID:JohnDeere,项目名称:MyJohnDeereAPI-OAuth-Java-Client,代码行数:8,代码来源:RestRequest.java

示例12: signRequest

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
@Override
public void signRequest(HttpURLConnection apiRequest) {
	OAuthConsumer consumer = new DefaultOAuthConsumer(apiConsumerKey, apiConsumerSecret);

	consumer.setTokenWithSecret(accessToken, accessSecret);
	try {
		consumer.sign(apiRequest);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:ImmobilienScout24,项目名称:restapi-java-sdk,代码行数:12,代码来源:IS24ApiImpl.java

示例13: createOAuthConsumer

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
/**
 * Creates an oauth consumer used for signing request URLs.
 *
 * @return The OAuthConsumer.
 */
public static OAuthConsumer createOAuthConsumer(String clientId, String clientSecret) {
    OAuthConsumer consumer =
        new DefaultOAuthConsumer(clientId, clientSecret);
    consumer.setSigningStrategy(new QueryStringSigningStrategy());
    return consumer;
}
 
开发者ID:openmhealth,项目名称:shimmer,代码行数:12,代码来源:OAuth1Utils.java

示例14: prepare

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
private HttpURLConnection prepare(URL url, String method) {
    if (this.username != null && this.password != null && this.scheme != null) {
        String authString = null;
        switch (this.scheme) {
        case BASIC: authString = basicAuthHeader(); break;
        default: throw new RuntimeException("Scheme " + this.scheme + " not supported by the UrlFetch WS backend.");
        }
        this.headers.put("Authorization", authString);
    }
    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod(method);
        connection.setDoInput(true);
        connection.setInstanceFollowRedirects(this.followRedirects);
        connection.setReadTimeout(this.timeout * 1000);
        for (String key: this.headers.keySet()) {
            connection.setRequestProperty(key, headers.get(key));
        }
        checkFileBody(connection);
        if (this.oauthToken != null && this.oauthSecret != null) {
            OAuthConsumer consumer = new DefaultOAuthConsumer(oauthInfo.consumerKey, oauthInfo.consumerSecret);
            consumer.setTokenWithSecret(oauthToken, oauthSecret);
            consumer.sign(connection);
        }
        return connection;
    } catch(Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:30,代码来源:WSUrlFetch.java

示例15: retrieveRequestToken

import oauth.signpost.basic.DefaultOAuthConsumer; //导入依赖的package包/类
/**
 * Request the request token and secret.
 * @param callbackURL the URL where the provider should redirect to
 * @return a Response object holding either the result in case of a success or the error
 */
public Response retrieveRequestToken(String callbackURL) {
    OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
    try {
        provider.retrieveRequestToken(consumer, callbackURL);
    } catch (OAuthException e) {
        return Response.error(new Error(e));
    }
    return Response.success(consumer.getToken(), consumer.getTokenSecret());
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:15,代码来源:OAuth.java


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