本文整理匯總了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());
}
}
}
示例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);
}
}
示例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());
}
示例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;
}
示例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));
}
示例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());
}