• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OAuthException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * Run the sample app with the provided arguments.
 * @param args
 * @throws OAuthException
 * @throws IOException
 * @throws ServiceException
 */
public static void main(String[] args) throws OAuthException, IOException, ServiceException {
  if (args.length != 3) {
    System.out.println("Usage: unshare_profile <consumerKey> <consumerSecret> <adminEmail>");
  } else {
    String consumerKey = args[0];
    String consumerSecret = args[1];
    String adminEmail = args[2];
    ProfilesManager manager = new ProfilesManager(consumerKey, consumerSecret, adminEmail);

    BatchResult result = manager.unshareProfiles();

    System.out.println("Success: " + result.getSuccess() + " - Error: " + result.getError());
    for (ContactEntry entry : result.getErrorEntries()) {
      BatchStatus status = BatchUtils.getBatchStatus(entry);

      System.out.println(" > Failed to update " + entry.getId() + ": (" + status.getCode() + ") "
          + status.getReason());
    }
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:28,代码来源:UnshareProfiles.java


示例2: getAuthorizationHeader

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * Generates the OAuth authorization header using the user's OAuth
 * parameters, the request url and the request method.
 *
 * @param requestUrl the URL being requested
 * @param requestMethod the HTTP method of the request
 * @return the authorization header to be used for the request
 */
public String getAuthorizationHeader(URL requestUrl, String requestMethod) {
  try {
    if (parameters.getOAuthType() == OAuthType.TWO_LEGGED_OAUTH) {
      TwoLeggedOAuthHelper twoLeggedOAuthHelper
          = new TwoLeggedOAuthHelper(signer, parameters);
      return twoLeggedOAuthHelper.getAuthorizationHeader(requestUrl.toString(),
          requestMethod);
    } else {
      GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);
      return oauthHelper.getAuthorizationHeader(requestUrl.toString(),
        requestMethod, parameters);
    }
  } catch (OAuthException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:25,代码来源:GoogleAuthTokenFactory.java


示例3: ProfilesManager

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * Constructor initializing the ContactsService object using 2-Legged OAuth authentication
 * @param consumerKey domain consumer key
 * @param consumerSecret domain consumer secret
 * @param adminEmail domain administrator to authenticate as
 */
public ProfilesManager(String consumerKey, String consumerSecret, String adminEmail)
    throws OAuthException {
  this.adminEmail = adminEmail;
  this.domain = adminEmail.substring(adminEmail.indexOf('@') + 1);

  GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
  oauthParameters.setOAuthConsumerKey(consumerKey);
  oauthParameters.setOAuthConsumerSecret(consumerSecret);

  this.myService = new ContactsService("GoogleInc-UnshareProfiles-1");
  this.myService.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:19,代码来源:UnshareProfiles.java


示例4: validateOauthSignature

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * @param oauthParams
 * @param secretKey
 * @return
 * @throws Exception
 */
private boolean validateOauthSignature(OAuthConsumerDTO oauthParams, String secretKey)
        throws AuthenticationException {

    GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
    oauthParameters.setOAuthConsumerKey(oauthParams.getOauthConsumerKey());
    oauthParameters.setOAuthConsumerSecret(secretKey);
    oauthParameters.setOAuthNonce(oauthParams.getOauthNonce());
    oauthParameters.setOAuthTimestamp(oauthParams.getOauthTimeStamp());
    oauthParameters.setOAuthSignatureMethod(oauthParams.getOauthSignatureMethod());

    validateTimestampAndNonce(oauthParams.getOauthTimeStamp(), oauthParams.getOauthNonce());

    OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();
    String signature;
    try {
        String baseString = OAuthUtil.getSignatureBaseString(oauthParams.getBaseString(),
                oauthParams.getHttpMethod(), oauthParameters.getBaseParameters());
        signature = signer.getSignature(baseString, oauthParameters);
    } catch (OAuthException e) {
        throw new AuthenticationException(e.getMessage(), e);
    }

    if (signature != null
            && URLEncoder.encode(signature).equals(oauthParams.getOauthSignature())) {
        return true;
    } else if (signature != null && signature.equals(oauthParams.getOauthSignature())) {
        return true;
    }
    return false;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:37,代码来源:OAuthService.java


示例5: setOAuthCredentials

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * Sets the OAuth credentials used to generate the authorization header.
 * The following OAuth parameters are required:
 * <ul>
 * <li>oauth_consumer_key
 * <li>oauth_token
 * </ul>
 *
 * @param parameters the OAuth parameters to use to generate the header
 * @param signer the signing method to use for signing the header
 * @throws OAuthException
 */
public void setOAuthCredentials(OAuthParameters parameters,
    OAuthSigner signer) throws OAuthException {
  // validate input parameters
  parameters.assertOAuthConsumerKeyExists();
  setAuthToken(new OAuthToken(parameters, signer));
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:19,代码来源:GoogleAuthTokenFactory.java


示例6: setOAuthCredentials

import com.google.gdata.client.authn.oauth.OAuthException; //导入依赖的package包/类
/**
 * Sets the OAuth credentials used to generate the authorization header.
 * This header needs to be set per request, as it depends on the request url.
 * The following OAuth parameters are required:
 * <ul>
 * <li>oauth_consumer_key
 * <li>oauth_token
 * </ul>
 *
 * @param parameters the OAuth parameters to use to generate the header
 * @param signer the signing method to use for signing the header
 */
public void setOAuthCredentials(OAuthParameters parameters,
    OAuthSigner signer) throws OAuthException {
  GoogleAuthTokenFactory googleAuthTokenFactory = getGoogleAuthTokenFactory();
  googleAuthTokenFactory.setOAuthCredentials(parameters, signer);
  requestFactory.setAuthToken(authTokenFactory.getAuthToken());
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:19,代码来源:GoogleService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TThreadPoolServer类代码示例发布时间:2022-05-16
下一篇:
Java OnDriverDistraction类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap