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


Java OAuthMessageSignerException类代码示例

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


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

示例1: sign

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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: sign

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
@Override
public String sign(HttpRequest request, HttpParameters requestParams)
    throws OAuthMessageSignerException {

  final OAuthRsaSigner signer = new OAuthRsaSigner();
  final byte[] privateBytes = Base64.decodeBase64(getConsumerSecret());
  final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateBytes);

  try {
    signer.privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
    final String signatureBaseString = new SignatureBaseString(request, requestParams).generate();
    return signer.computeSignature(signatureBaseString);
  } catch (GeneralSecurityException e) {
    throw new OAuthMessageSignerException(e);
  }
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:17,代码来源:RsaSha1MessageSigner.java

示例3: retrieveAccessToken_success

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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

示例4: getRequestToken

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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

示例5: getAccessToken

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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

示例6: downloadAndShowNews

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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

示例7: sign

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
@Override
public String sign(HttpRequest request, HttpParameters requestParams) throws OAuthMessageSignerException {
    byte[] decodedPrivateKey;
    try {
        decodedPrivateKey = Base64.decode(getConsumerSecret());
        String baseString = new SignatureBaseString(request, requestParams).generate();
        Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_TYPE);
        EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decodedPrivateKey);
        PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
        signature.initSign(privateKey);
        signature.update(baseString.getBytes());
        byte[] rsasha1 = signature.sign();
        return Base64.encode(rsasha1);
    } catch (IOException | NoSuchAlgorithmException | InvalidKeyException | InvalidKeySpecException | SignatureException e) {
        throw new OAuthMessageSignerException(e);
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:19,代码来源:RsaSha1MessageSigner.java

示例8: executePostJsonStreamingResponse

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
private HttpStreamResponse executePostJsonStreamingResponse(HttpEntityEnclosingRequestBase requestBase,
    String jsonBody,
    Map<String, String> headers) throws HttpClientException {
    try {
        setRequestHeaders(headers, requestBase);
        requestBase.setEntity(new StringEntity(jsonBody, ContentType.APPLICATION_JSON));
        requestBase.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
        return executeStream(requestBase);
    } catch (IOException | UnsupportedCharsetException | OAuthCommunicationException | OAuthExpectationFailedException |
        OAuthMessageSignerException e) {
        String trimmedMethodBody = (jsonBody.length() > JSON_POST_LOG_LENGTH_LIMIT)
            ? jsonBody.substring(0, JSON_POST_LOG_LENGTH_LIMIT) : jsonBody;
        throw new HttpClientException("Error executing " + requestBase.getMethod() + " request " +
            "to " + clientPathToString(requestBase.getURI().getPath()) + " body:" + trimmedMethodBody, e);
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:17,代码来源:ApacheHttpClient441BackedHttpClient.java

示例9: executeStream

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
private HttpStreamResponse executeStream(HttpRequestBase requestBase) throws OAuthMessageSignerException,
    OAuthExpectationFailedException,
    OAuthCommunicationException,
    IOException {
    applyHeadersCommonToAllRequests(requestBase);
    activeCount.incrementAndGet();
    CloseableHttpResponse response = client.execute(requestBase);
    StatusLine statusLine = response.getStatusLine();

    int status = statusLine.getStatusCode();
    if (status < 200 || status >= 300) {
        activeCount.decrementAndGet();
        HttpClientUtils.closeQuietly(response);
        requestBase.reset();
        throw new IOException("Bad status : " + statusLine);
    }

    return new HttpStreamResponse(statusLine.getStatusCode(),
        statusLine.getReasonPhrase(),
        response,
        response.getEntity().getContent(),
        requestBase,
        activeCount);
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:25,代码来源:ApacheHttpClient441BackedHttpClient.java

示例10: getAuthoriseAppUrl

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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

示例11: requestObjectApi

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
private static void requestObjectApi( OAuthConsumer consumer ) throws MalformedURLException, IOException, OAuthMessageSignerException,
  OAuthExpectationFailedException, OAuthCommunicationException, UnsupportedEncodingException
{

  LOGGER.info( "#################################################################################################" );

  URL url =
    new URL( "http://sandbox.immobilienscout24.de/restapi/api/search/v1.0/searcher/abc" );

  HttpURLConnection apiRequest = (HttpURLConnection) url.openConnection();

  consumer.sign( apiRequest );
  LOGGER.info( "Sending request..." );

  apiRequest.connect();
  LOGGER.info( "Expiration "+apiRequest.getExpiration() );
  LOGGER.info( "Timeout "+apiRequest.getConnectTimeout() );
  LOGGER.info( "URL "+apiRequest.getURL() );
  LOGGER.info( "Method "+apiRequest.getRequestMethod() );

  LOGGER.info( "Response: "+apiRequest.getResponseCode()+" "
    +apiRequest.getResponseMessage() );

  LOGGER.info( "#################################################################################################" );
}
 
开发者ID:OpenEstate,项目名称:OpenEstate-IS24-REST,代码行数:26,代码来源:IS24OauthExample.java

示例12: stream

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
public ContentExchange stream(ContentExchange ex, Symbol... symbols) throws ModelException
{
	OAuthConsumer consumer = new JettyOAuthConsumer(ForemanConstants.API_KEY.toString(), ForemanConstants.API_SECRET.toString());
	consumer.setTokenWithSecret(ForemanConstants.ACCESS_TOKEN.toString(), ForemanConstants.ACCESS_TOKEN_SECRET.toString());

	ex.setMethod(Verb.GET.name());
	ex.setURL(APICall.getStreamingQuote(ResponseFormat.XML) + getParameters(symbols));

	// sign the request
	try
	{
		consumer.sign(ex);
		client.send(ex);
	}
	catch (IOException | OAuthMessageSignerException | OAuthExpectationFailedException | OAuthCommunicationException e)
	{
		throw new ModelException("Sent Exchange to Client", e);
	}

	return ex;
}
 
开发者ID:Ccook,项目名称:conniption,代码行数:22,代码来源:StreamingMarketQuote.java

示例13: sign

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
@Override
public String sign(HttpRequest request, HttpParameters requestParams) throws OAuthMessageSignerException {

	final OAuthRsaSigner signer = new OAuthRsaSigner();
	final byte[] privateBytes = Base64.decodeBase64(getConsumerSecret());
	final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateBytes);

	try {
		signer.privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
		final String signatureBaseString = new SignatureBaseString(request, requestParams).generate();
		return signer.computeSignature(signatureBaseString);
	} catch (GeneralSecurityException e) {
		throw new OAuthMessageSignerException(e);
	}
}
 
开发者ID:ThoughtsLive,项目名称:jira-steps,代码行数:16,代码来源:RsaSha1MessageSigner.java

示例14: prepareConnection_throwsExceptionWhenSigningFailed

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的package包/类
@Test
public void prepareConnection_throwsExceptionWhenSigningFailed() throws Exception {
	OAuthConsumer someCrashingConsumer = mock(OAuthConsumer.class);
	when(someCrashingConsumer.sign(any(Object.class))).thenThrow(new OAuthMessageSignerException("could not sign :("));

	requestFactory = new OAuthSignedClientHttpRequestFactory(someCrashingConsumer);

	assertThatThrownBy(() -> requestFactory.prepareConnection(connectionTo("http://some-domain.com"), "GET"))
			.hasMessage("Could not sign request to http://some-domain.com")
			.hasCauseExactlyInstanceOf(OAuthMessageSignerException.class);
}
 
开发者ID:AppDirect,项目名称:service-integration-sdk,代码行数:12,代码来源:OAuthSignedClientHttpRequestFactoryTest.java

示例15: retrieveRequestToken_success

import oauth.signpost.exception.OAuthMessageSignerException; //导入依赖的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


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