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


Java CommonsHttpOAuthConsumer类代码示例

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


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

示例1: sign

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
@Override
public HttpRequest sign(HttpRequest request, String key, String secret) throws LtiSigningException {
    CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
    try {
        String body = getRequestBody(request);
        String bodyHash = new String(Base64.encodeBase64(md.digest(body.getBytes())));

        HttpParameters params = new HttpParameters();
        params.put("oauth_body_hash", URLEncoder.encode(bodyHash, "UTF-8"));
        signer.setAdditionalParameters(params);

        signer.sign(request);
    } catch (OAuthMessageSignerException|OAuthExpectationFailedException|OAuthCommunicationException|IOException e) {
        throw new LtiSigningException("Exception encountered while singing Lti request...", e);
    }
    return request;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:LtiOauthSigner.java

示例2: buildReplaceResult

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
public static HttpPost buildReplaceResult(String url, String key, String secret, String sourcedid, String score, String resultData, Boolean isUrl) throws IOException, OAuthException, GeneralSecurityException {
	String dataXml = "";
	if (resultData != null) {
		String format = isUrl ? resultDataUrl : resultDataText;
		dataXml = String.format(format, StringEscapeUtils.escapeXml(resultData));
	}
	//*LAMS* the following line was added by LAMS and also messageIdentifier was added to the line after it
	String messageIdentifier = UUID.randomUUID().toString();
	String xml = String.format(replaceResultMessage, messageIdentifier, StringEscapeUtils.escapeXml(sourcedid),
			StringEscapeUtils.escapeXml(score), dataXml);

	HttpParameters parameters = new HttpParameters();
	String hash = getBodyHash(xml);
	parameters.put("oauth_body_hash", URLEncoder.encode(hash, "UTF-8"));

	CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
	HttpPost request = new HttpPost(url);
	request.setHeader("Content-Type", "application/xml");
	request.setEntity(new StringEntity(xml, "UTF-8"));
	signer.setAdditionalParameters(parameters);
	signer.sign(request);
	return request;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:IMSPOXRequest.java

示例3: getServiceOAuthSigner

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
private OAuthSigner getServiceOAuthSigner() throws Exception {
    String password = keyStorePassword(instanceConfig.getRoutesHost(), instanceConfig.getRoutesPort());
    File oauthKeystoreFile = new File("./certs/oauthKeystore");
    RSAKeyPairGenerator generator = new RSAKeyPairGenerator();
    String consumerKey = instanceConfig.getInstanceKey();
    String consumerSecret = generator.getPrivateKey(consumerKey, password, oauthKeystoreFile);

    String token = consumerKey;
    String tokenSecret = consumerSecret;

    return (request) -> {
        CommonsHttpOAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
        oAuthConsumer.setMessageSigner(new RsaSha1MessageSigner());
        oAuthConsumer.setTokenWithSecret(token, tokenSecret);
        return oAuthConsumer.sign(request);
    };
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:18,代码来源:Deployable.java

示例4: Twitter_Handler

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
public Twitter_Handler(Activity context, String consumerKey,
		String secretKey) {
	this.context = context;

	twitterObj = new TwitterFactory().getInstance();

	mSession = new TwitterSession(context);
	mProgressDlg = new ProgressDialog(context);

	mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);

	mConsumerKey = consumerKey;
	mSecretKey = secretKey;

	mHttpOauthConsumer = new CommonsHttpOAuthConsumer(mConsumerKey,mSecretKey);

	String request_url = TWITTER_REQUEST_URL;
	String access_token_url = TWITTER_ACCESS_TOKEN_URL;
	String authorize_url = TWITTER_AUTHORZE_URL;

	mHttpOauthprovider = new DefaultOAuthProvider(request_url,
			access_token_url, authorize_url);
	mAccessToken = mSession.getAccessToken();

	configureToken();
}
 
开发者ID:ohmp,项目名称:UniversalSocialLoginAndroid,代码行数:27,代码来源:Twitter_Handler.java

示例5: getMockedClient

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
private OAuthClient getMockedClient() throws Exception {
	when(properties.getProperty("consumerKey")).thenReturn("key");
	when(properties.getProperty("consumerSecret")).thenReturn("secret");
	
	final FileInputStream fileInputStreamMock = PowerMockito.mock(FileInputStream.class);
       PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString())
                           .thenReturn(fileInputStreamMock);
	
	PowerMockito.whenNew(CommonsHttpOAuthConsumer.class).withArguments(Matchers.anyString(), Matchers.anyString())
                           .thenReturn(CommonsHttpOAuthConsumerMock);
       
       PowerMockito.whenNew(CommonsHttpOAuthProvider.class).withArguments(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())
       					.thenReturn(CommonsHttpOAuthProviderMock);
       
       Config config = new Config(properties);
	
	OAuthClient client = new OAuthClient(config);
	
	return client;
}
 
开发者ID:upwork,项目名称:java-upwork,代码行数:21,代码来源:OAuthClientTest.java

示例6: doInBackground

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
@Override
protected String doInBackground(String... params){
	try{
        this.consumer = new CommonsHttpOAuthConsumer(myConstants.CONDUCTTR_CONSUMER_KEY,
        		myConstants.CONDUCTTR_CONSUMER_SECRET);
		this.consumer.setTokenWithSecret(myConstants.CONDUCTTR_ACCESS_TOKEN, myConstants.CONDUCTTR_ACCESS_TOKEN_SECRET);	

		String url = myConstants.CONDUCTTR_BASE_URL + myConstants.CONDUCTTR_PROJECT_ID + "/" ;
		HttpPost request = new HttpPost(url);
		List<NameValuePair> params1 = new ArrayList<NameValuePair>();
  		params1.add(new BasicNameValuePair("audience_phone", audience_phone.getText().toString() ));
  		
  		request.setEntity(new UrlEncodedFormEntity(params1));
		
		consumer.sign(request);
        HttpClient httpClient = new DefaultHttpClient();
        //HttpResponse response = httpClient.execute(request);
        httpClient.execute(request);
	}
	catch(Exception e){
		e.printStackTrace();
		resp = e.getMessage();
	}
	return resp;
}
 
开发者ID:Conducttr,项目名称:SkunkWrx,代码行数:26,代码来源:MainActivity.java

示例7: doInBackground

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
@Override
protected String doInBackground(String... params){
	try{
        this.consumer = new CommonsHttpOAuthConsumer(myConstants.CONDUCTTR_CONSUMER_KEY,
        		myConstants.CONDUCTTR_CONSUMER_SECRET);
		this.consumer.setTokenWithSecret(myConstants.CONDUCTTR_ACCESS_TOKEN, myConstants.CONDUCTTR_ACCESS_TOKEN_SECRET);	
		String url = myConstants.CONDUCTTR_BASE_URL + myConstants.CONDUCTTR_PROJECT_ID + "/registration" ;

		HttpPost request = new HttpPost(url);
		List<NameValuePair> params1 = new ArrayList<NameValuePair>();
  		params1.add(new BasicNameValuePair("audience_phone", audience_phone.getText().toString() ));

  		request.setEntity(new UrlEncodedFormEntity(params1));
		
		consumer.sign(request);
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = httpClient.execute(request);
        resp="okidoki";
       
	}
	catch(Exception e){
		e.printStackTrace();
		resp = e.getMessage();
	}
	return resp;
}
 
开发者ID:Conducttr,项目名称:SkunkWrx,代码行数:27,代码来源:MainActivity.java

示例8: ToopherAPI

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
/**
 * Create an API object with the supplied credentials, overriding the default API URI of https://api.toopher.com/v1/
 *
 * @param consumerKey
 *            The consumer key for a requester (obtained from the developer portal)
 * @param consumerSecret
 *            The consumer secret for a requester (obtained from the developer portal)
 * @param uri
 *            The alternate URI
 */
public ToopherAPI(String consumerKey, String consumerSecret, URI uri) {
    httpClient = new DefaultHttpClient();
    HttpProtocolParams.setUserAgent(httpClient.getParams(),
                                    String.format("ToopherJava/%s", VERSION));

    consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
    if (uri == null) {
        this.uriScheme = ToopherAPI.DEFAULT_URI_SCHEME;
        this.uriHost = ToopherAPI.DEFAULT_URI_HOST;
        this.uriPort = ToopherAPI.DEFAULT_URI_PORT;
        this.uriBase = ToopherAPI.DEFAULT_URI_BASE;
    } else {
        this.uriScheme = uri.getScheme();
        this.uriHost = uri.getHost();
        this.uriPort = uri.getPort();
        this.uriBase = uri.getPath();
    }
}
 
开发者ID:toopher,项目名称:toopher-pingfederate,代码行数:29,代码来源:ToopherAPI.java

示例9: TwitterHttpClient

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
/**
 * Creates a twitter consumer by all the secrets
 * 
 * @param consumerKey consumer key
 * @param consumerSecret consumer secret
 * @param token token
 * @param tokenSecret token secret
 */
public TwitterHttpClient(String consumerKey, String consumerSecret, String token, String tokenSecret) {
	
	// Create default http client
	HttpParams httpParams = new BasicHttpParams();
	SchemeRegistry registry = new SchemeRegistry();
	registry.register(new Scheme("http", new PlainSocketFactory(), 80));
	registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
       
	httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, registry), httpParams);
	
	// Set consumer
	consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
	consumer.setTokenWithSecret(token, tokenSecret);
	
}
 
开发者ID:BakingCode,项目名称:ara-twitter,代码行数:24,代码来源:TwitterHttpClient.java

示例10: TwitterApp

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
private TwitterApp(Context context, String consumerKey, String secretKey) {
	this.context	= context;
	
	mTwitter 		= new TwitterFactory().getInstance();
	mSession		= new TwitterSession(context);
	mProgressDlg	= new ProgressDialog(context);
	
	mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
	
	mConsumerKey 	= consumerKey;
	mSecretKey	 	= secretKey;

	mHttpOauthConsumer = new CommonsHttpOAuthConsumer(mConsumerKey, mSecretKey);
	mHttpOauthprovider = new DefaultOAuthProvider("https://api.twitter.com/oauth/request_token	",
												 "https://api.twitter.com/oauth/access_token",
												 "https://api.twitter.com/oauth/authorize");
	
	mAccessToken	= mSession.getAccessToken();
	
	configureToken();
}
 
开发者ID:kodamirmo,项目名称:LostAndFound,代码行数:22,代码来源:TwitterApp.java

示例11: run

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
public void run() {
  JSONObject statement = buildStatement();
  
  LTIConsumer consumer = user.getConsumer();
  String key = consumer.getKey().toString();
  String secret = consumer.getSecret().toString();
  OAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
  
  try {
    HttpPost request = new HttpPost(user.getXapiUrl());
    request.setHeader("Content-Type", "application/json");
    request.setEntity(new StringEntity(statement.toString(), "UTF-8"));
    signer.sign(request);
    DefaultHttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(request);
    if (response.getStatusLine().getStatusCode() >= 400) {
      throw new Exception(response.getStatusLine().getReasonPhrase());
    }
  } catch (Exception e) {
    MinecraftLTI.instance.getLogger().warning("Failed to send duration: "+e.getMessage());
  }
}
 
开发者ID:instructure,项目名称:MinecraftLTI,代码行数:23,代码来源:DurationRunner.java

示例12: onCreate

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	
	super.onCreate(savedInstanceState);
   	try {

   		System.setProperty("debug", "true");
   	    this.consumer = new CommonsHttpOAuthConsumer(OAuthConstants.CONSUMER_KEY, OAuthConstants.CONSUMER_SECRET);
   	    this.provider = new CommonsHttpOAuthProvider(
   	    		OAuthConstants.REQUEST_URL  + "?scope=" + URLEncoder.encode(OAuthConstants.SCOPE, OAuthConstants.ENCODING),
   	        	OAuthConstants.ACCESS_URL  + "?scope=" + URLEncoder.encode(OAuthConstants.SCOPE, OAuthConstants.ENCODING),
   	        	OAuthConstants.AUTHORIZE_URL);
       	} catch (Exception e) {
       		
       		Log.e(TAG, "Error creating consumer / provider",e);
   		}

       Log.i(TAG, "Starting task to retrieve request token.");
	new OAuthRequestTokenTask(this,consumer,provider).execute();
}
 
开发者ID:OneStopTransport,项目名称:OAuth-1-android-demo,代码行数:21,代码来源:PrepareRequestTokenActivity.java

示例13: doOAuth

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
public void doOAuth() {
	try {
		OAuthConsumer consumer = new CommonsHttpOAuthConsumer(ShapewaysApplication.CONSUMER_KEY, ShapewaysApplication.CONSUMER_SECRET);

		consumer.setTokenWithSecret(((ShapewaysApplication) getApplicationContext()).getShapewaysClient().getOauthToken(),
				((ShapewaysApplication) getApplicationContext()).getShapewaysClient().getOauthTokenSecret());

		// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d5e68
		HttpGet request = new HttpGet(ShapewaysClient.API_URL_BASE + ShapewaysClient.API_PATH);

		consumer.sign(request);

		HttpClient httpClient = new DefaultHttpClient();
		HttpResponse response = httpClient.execute(request);
		Log.d(LOG_TAG, "response=" + response.getStatusLine());
		Log.d(LOG_TAG, "response=" + EntityUtils.toString(response.getEntity()));
	} catch (Exception e) {
		Log.e(LOG_TAG, "doOAuth", e);
	}
}
 
开发者ID:entertailion,项目名称:Android-Shapeways,代码行数:21,代码来源:MainActivity.java

示例14: onCreate

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) 
{   
	super.onCreate(savedInstanceState);
	//设置屏幕没有标题栏
	requestWindowFeature(Window.FEATURE_NO_TITLE); 
	setContentView(R.layout.welcome);
	
	webInstance = this;
       mContext = getApplicationContext();
       accessInfo = InfoHelper.getAccessInfo(mContext);
       
       //生成consumer,consumer代表我们自己开发的应用JSU
   	consumer = new CommonsHttpOAuthConsumer(ConstantsUtils.CONSUMER_KEY, 
   			ConstantsUtils.CONSUMER_SECRET);
   	
   	//生成provider,provider代表新浪微博,传入认证需要的三个地址
	provider = new DefaultOAuthProvider(
			UrlUtils.REQUEST_TOKEN,
			UrlUtils.ACCESS_TOKEN,
			UrlUtils.AUTHORIZE);
}
 
开发者ID:zzxadi,项目名称:WeiboJSU,代码行数:23,代码来源:WelcomeActivity.java

示例15: IOSTwitterAPI

import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; //导入依赖的package包/类
public IOSTwitterAPI(TwitterConfig config) {
	super(config);

	consumer = new CommonsHttpOAuthConsumer(config.TWITTER_CONSUMER_KEY, config.TWITTER_CONSUMER_SECRET);
	provider = new CommonsHttpOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token",
			"https://api.twitter.com/oauth/authorize");

}
 
开发者ID:TomGrill,项目名称:gdx-twitter,代码行数:9,代码来源:IOSTwitterAPI.java


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