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


Java OAuthNotAuthorizedException类代码示例

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


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

示例1: retrieveAccessToken_success

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
@Test
public void retrieveAccessToken_success() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException {
    Uri uri = mock(Uri.class);
    String verifier = "some verifier";
    when(uri.getQueryParameter(OAuth.OAUTH_VERIFIER)).thenReturn(verifier);

    String userTokenString = "some token";
    when(okHttpOAuthConsumer.getToken()).thenReturn(userTokenString);

    String userTokenSecretString = "some secret token";
    when(okHttpOAuthConsumer.getTokenSecret()).thenReturn(userTokenSecretString);


    TestSubscriber testSubscriber = new TestSubscriber();
    oAuthInteractor.retrieveAccessToken(uri)
            .subscribe(testSubscriber);

    testSubscriber.assertCompleted();

    verify(okHttpOAuthProvider, times(1)).retrieveAccessToken(okHttpOAuthConsumer, verifier);
    verify(userToken, times(1)).set(userTokenString);
    verify(userTokenSecret, times(1)).set(userTokenSecretString);
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:24,代码来源:OAuthInteractorTest.java

示例2: getRequestToken

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
/**
 * This method request a request token and saves the received authUrl in the
 * global variable
 * 
 * @return true if success; false otherwise
 */
public ResponseCode getRequestToken() {
    logger.entry();

    if (isAuthorized) {
        return logger.exit(ResponseCode.APPLICATION_ALREADY_AUTHORIZED);
    }

    mProvider = new DefaultOAuthProvider(mServer.getRequestUrl(), mServer.getAccessUrl(),
            mServer.getAuthorizationUrl());
    try {
        authUrl = mProvider.retrieveRequestToken(mConsumer, "http://studip-client.danner-web.de/callback");
    } catch (OAuthMessageSignerException | OAuthNotAuthorizedException | OAuthExpectationFailedException
            | OAuthCommunicationException e) {
        logger.debug("Unable to fetch oauth_request_token");
        return logger.exit(ResponseCode.SERVER_NOT_REACHABLE);
    }

    return logger.exit(ResponseCode.SUCCESS);
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:26,代码来源:OAuthConnector.java

示例3: getAccessToken

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public ResponseCode getAccessToken() {

        if (isAuthorized) {
            return logger.exit(ResponseCode.APPLICATION_ALREADY_AUTHORIZED);
        }

        if (mProvider != null) {
            try {
                mProvider.retrieveAccessToken(mConsumer, OAuth.OUT_OF_BAND);

                mServer.setAccessToken(mConsumer.getToken());
                mServer.setAccessTokenSecret(mConsumer.getTokenSecret());

                isAuthorized = true;

            } catch (OAuthMessageSignerException | OAuthNotAuthorizedException | OAuthExpectationFailedException
                    | OAuthCommunicationException e) {
                logger.debug("Unable to fetch oauth_access_token");
                return logger.exit(ResponseCode.APPLICATION_NOT_AUTHORIZED);
            }
        }
        return logger.exit(ResponseCode.SUCCESS);
    }
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:24,代码来源:OAuthConnector.java

示例4: downloadAndShowNews

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
/**
 * Helper method to download and show all news within the given range.
 * 
 * @param range
 * @return 0 if success, otherwise error code
 */
private int downloadAndShowNews(NewsRange range) {
	HttpURLConnection connection = null;
	try {
		connection = con.get(getUnreadNewsFromRange(range));
	} catch (OAuthNotAuthorizedException | OAuthMessageSignerException | OAuthExpectationFailedException
			| OAuthCommunicationException e) {
		e.printStackTrace();
	}
	if (connection == null) {
		return 500;
	}

	List<News> newsList = JSONParserUtil.parse(connection, News.class);
	if (newsList != null) {
		for (News news : newsList) {
			SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
			Date dt = new Date(Long.valueOf(news.date) * 1000);
			String time = sdf.format(dt);
			context.appendPopup(new TextPluginMessage(news.topic + " (" + news.author + " " + time + ")",
					news.body, new NewsListener(news)));
		}
	}
	return 0;
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:31,代码来源:NewsPlugin.java

示例5: getAuthoriseAppUrl

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public static String getAuthoriseAppUrl(Context context)
		throws OAuthMessageSignerException, OAuthNotAuthorizedException,
		OAuthExpectationFailedException, OAuthCommunicationException {

	/**
	 * You will want to set customProtocol to something unique to avoid
	 * having Android give the user more than one app to pick from to handle
	 * the oauth callback. A good option would be to use something derived
	 * from your package name.
	 */
	String customProtocol = context.getResources().getString(
			R.string.customAppProtocol);

	return provider.retrieveRequestToken(consumer, customProtocol
			+ "://oauth");
}
 
开发者ID:OpenBankProject,项目名称:Hello-OBP-OAuth1.0a-Android,代码行数:17,代码来源:OBPRestClient.java

示例6: setHttpClient

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
/**
 * Use a specific {@link HttpClient} for HTTP traffic.
 *
 * @param httpClient
 * {@link HttpClient}, that is used for HTTP communication
 */
public synchronized void setHttpClient( HttpClient httpClient )
{
  this.httpClient = httpClient;

  // register HTTP client in the OAuth provider
  try
  {
    OAuthProvider p = getAuthProvider();
    if (p instanceof CommonsHttpOAuthProvider)
    {
      ((CommonsHttpOAuthProvider) p).setHttpClient( httpClient );
    }
  }
  catch (OAuthNotAuthorizedException ex)
  {
  }
}
 
开发者ID:OpenEstate,项目名称:OpenEstate-IS24-REST,代码行数:24,代码来源:HttpComponents43Client.java

示例7: retrieveRequestToken_success

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
@Test
public void retrieveRequestToken_success() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException {
    String token = "some token";
    when(okHttpOAuthProvider.retrieveRequestToken(any(), anyString())).thenReturn(token);

    TestSubscriber<String> testSubscriber = new TestSubscriber<>();
    oAuthInteractor.retrieveRequestToken()
            .subscribe(testSubscriber);

    testSubscriber.assertValue(token);
    verify(okHttpOAuthProvider, times(1)).retrieveRequestToken(okHttpOAuthConsumer, ApiConstants.OAUTH_CALLBACK);
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:13,代码来源:OAuthInteractorTest.java

示例8: retrieveRequestToken_error

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
@Test
public void retrieveRequestToken_error() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException {
    Throwable throwable = new RuntimeException();
    when(okHttpOAuthProvider.retrieveRequestToken(any(), anyString())).thenThrow(throwable);

    TestSubscriber<String> testSubscriber = new TestSubscriber<>();
    oAuthInteractor.retrieveRequestToken()
            .subscribe(testSubscriber);

    testSubscriber.assertError(throwable);
    verify(okHttpOAuthProvider, times(1)).retrieveRequestToken(okHttpOAuthConsumer, ApiConstants.OAUTH_CALLBACK);
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:13,代码来源:OAuthInteractorTest.java

示例9: retrieveAccessToken_error

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
@Test
public void retrieveAccessToken_error() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException {
    Uri uri = mock(Uri.class);
    when(uri.getQueryParameter(OAuth.OAUTH_VERIFIER)).thenReturn(null);

    TestSubscriber testSubscriber = new TestSubscriber();
    oAuthInteractor.retrieveAccessToken(uri)
            .subscribe(testSubscriber);

    // We don't really care what the error is just that we have one
    // Hacky way to see if there is an error (terminal event) but not success (completion)
    testSubscriber.assertTerminalEvent();
    testSubscriber.assertNotCompleted();
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:15,代码来源:OAuthInteractorTest.java

示例10: doInBackground

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
    try {
        mUrl = mOAuthHelper.getAuthorizationUrl();
        mFailed = false;
    } catch (OAuthNotAuthorizedException | OAuthExpectationFailedException |
            OAuthMessageSignerException | OAuthCommunicationException e) {
        mFailed = true;
    }
    return null;
}
 
开发者ID:lkorth,项目名称:photo-paper,代码行数:12,代码来源:FiveHundredPxOAuthActivity.java

示例11: Error

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
private Error(OAuthException exception) {
    this.exception = exception;
    if (this.exception instanceof OAuthMessageSignerException) {
        this.type = Type.MESSAGE_SIGNER;
    } else if (this.exception instanceof OAuthNotAuthorizedException) {
        this.type = Type.NOT_AUTHORIZED;
    } else if (this.exception instanceof OAuthExpectationFailedException) {
        this.type = Type.EXPECTATION_FAILED;
    } else if (this.exception instanceof OAuthCommunicationException) {
        this.type = Type.COMMUNICATION;
    } else {
        this.type = Type.OTHER;
    }
    this.details = exception.getMessage();
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:16,代码来源:OAuth.java

示例12: post

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public HttpURLConnection post(String pattern, String json) throws OAuthNotAuthorizedException,
        OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException {
    return sign(pattern, Method.POST, json);
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:5,代码来源:OAuthConnector.java

示例13: get

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public HttpURLConnection get(String pattern) throws OAuthNotAuthorizedException, OAuthMessageSignerException,
        OAuthExpectationFailedException, OAuthCommunicationException {
    return sign(pattern, Method.GET, "");
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:5,代码来源:OAuthConnector.java

示例14: put

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public HttpURLConnection put(String pattern) throws OAuthNotAuthorizedException, OAuthMessageSignerException,
        OAuthExpectationFailedException, OAuthCommunicationException {
    return sign(pattern, Method.PUT, "");
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:5,代码来源:OAuthConnector.java

示例15: delete

import oauth.signpost.exception.OAuthNotAuthorizedException; //导入依赖的package包/类
public HttpURLConnection delete(String pattern) throws OAuthNotAuthorizedException, OAuthMessageSignerException,
        OAuthExpectationFailedException, OAuthCommunicationException {
    return sign(pattern, Method.DELETE, "");
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:5,代码来源:OAuthConnector.java


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