本文整理汇总了Java中net.oauth.OAuthMessage.getConsumerKey方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthMessage.getConsumerKey方法的具体用法?Java OAuthMessage.getConsumerKey怎么用?Java OAuthMessage.getConsumerKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.oauth.OAuthMessage
的用法示例。
在下文中一共展示了OAuthMessage.getConsumerKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConsumer
import net.oauth.OAuthMessage; //导入方法依赖的package包/类
public static synchronized OAuthConsumer getConsumer(
OAuthMessage requestMessage)
throws IOException, OAuthProblemException {
OAuthConsumer consumer = null;
// try to load from local cache if not throw exception
String consumer_key = requestMessage.getConsumerKey();
consumer = SampleOAuthProvider.ALL_CONSUMERS.get(consumer_key);
if(consumer == null) {
OAuthProblemException problem = new OAuthProblemException("token_rejected");
throw problem;
}
return consumer;
}
示例2: authenticate
import net.oauth.OAuthMessage; //导入方法依赖的package包/类
@Override
public String authenticate(HttpServletRequest request) throws IOException, OAuthException,
URISyntaxException {
OAuthMessage message = OAuthServlet.getMessage(request, null);
String consumerKey = message.getConsumerKey();
String signatureMethod = message.getSignatureMethod();
OAuthConsumer consumer = keyManager.getOAuthConsumer(provider, consumerKey, signatureMethod);
if (null == consumer) {
logger.info("signed fetch verification failed: consumer is null");
throw new OAuthException("Unauthorized");
}
OAuthAccessor accessor = new OAuthAccessor(consumer);
message.validateMessage(accessor, validator);
String viewerEmail = message.getParameter("opensocial_viewer_email");
if (viewerEmail == null) {
logger.info("signed fetch verification failed: viewer email is null");
throw new OAuthException("Missing user identity opensocial_viewer_email");
}
// Retrieve and set the user info with the OAuth parameters
Map<UserInfoProperties, Object> oauthParams = new HashMap<UserInfoProperties, Object>();
oauthParams.put(UserInfoProperties.EMAIL, urlDecode(viewerEmail));
oauthParams.put(UserInfoProperties.VIEWER_ID, message.getParameter("opensocial_viewer_id"));
oauthParams.put(UserInfoProperties.OWNER_EMAIL,
urlDecode(message.getParameter("opensocial_owner_email")));
oauthParams.put(UserInfoProperties.OWNER_ID, message.getParameter("opensocial_owner_id"));
oauthParams.put(UserInfoProperties.APPLICATION_ID, message.getParameter("opensocial_app_id"));
oauthParams.put(UserInfoProperties.APPLICATION_URL, message.getParameter("opensocial_app_url"));
UserInfo userInfo = new HashMapBasedUserInfo(oauthParams);
request.setAttribute(AbstractManagedCollectionAdapter.USER_INFO, userInfo);
logger.info("signed fetch verified: " + viewerEmail);
return message.getParameter("opensocial_viewer_id");
}
示例3: createRequestToken
import net.oauth.OAuthMessage; //导入方法依赖的package包/类
private void createRequestToken(ContextResource contextResource) throws IOException, OAuthException, URISyntaxException {
OAuthMessage requestMessage = getOAuthMessage(contextResource.getRequest());
String consumerKey = requestMessage.getConsumerKey();
if (consumerKey == null) {
OAuthProblemException e = new OAuthProblemException(OAuth.Problems.PARAMETER_ABSENT);
e.setParameter(OAuth.Problems.OAUTH_PARAMETERS_ABSENT, OAuth.OAUTH_CONSUMER_KEY);
throw e;
}
OAuthConsumer consumer = dataStore.getConsumer(consumerKey);
if (consumer == null) {
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
}
OAuthAccessor accessor = new OAuthAccessor(consumer);
VALIDATOR.validateMessage(requestMessage, accessor);
String callback = requestMessage.getParameter(OAuth.OAUTH_CALLBACK);
if (callback == null) {
// see if the consumer has a callback
callback = consumer.callbackURL;
}
if (callback == null) {
callback = "oob";
}
// generate request_token and secret
OAuthEntry entry = dataStore.generateRequestToken(consumerKey, requestMessage.getParameter(OAuth.OAUTH_VERSION), callback);
List<Parameter> responseParams = OAuth.newList(OAuth.OAUTH_TOKEN, entry.getToken(), OAuth.OAUTH_TOKEN_SECRET, entry.getTokenSecret());
if (callback != null) {
responseParams.add(new Parameter(OAuth.OAUTH_CALLBACK_CONFIRMED, "true"));
}
sendResponse(contextResource, responseParams);
}
示例4: getValidatedEntry
import net.oauth.OAuthMessage; //导入方法依赖的package包/类
private OAuthEntry getValidatedEntry(OAuthMessage requestMessage) throws IOException, ServletException, OAuthException, URISyntaxException {
OAuthEntry entry = dataStore.getEntry(requestMessage.getToken());
if (entry == null) {
throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
}
if (entry.getType() != OAuthEntry.Type.REQUEST) {
throw new OAuthProblemException(OAuth.Problems.TOKEN_USED);
}
if (entry.isExpired()) {
throw new OAuthProblemException(OAuth.Problems.TOKEN_EXPIRED);
}
// find consumer key, compare with supplied value, if present.
if (requestMessage.getConsumerKey() == null) {
OAuthProblemException e = new OAuthProblemException(OAuth.Problems.PARAMETER_ABSENT);
e.setParameter(OAuth.Problems.OAUTH_PARAMETERS_ABSENT, OAuth.OAUTH_CONSUMER_KEY);
throw e;
}
String consumerKey = entry.getConsumerKey();
if (!consumerKey.equals(requestMessage.getConsumerKey())) {
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_REFUSED);
}
OAuthConsumer consumer = dataStore.getConsumer(consumerKey);
if (consumer == null) {
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
}
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.requestToken = entry.getToken();
accessor.tokenSecret = entry.getTokenSecret();
VALIDATOR.validateMessage(requestMessage, accessor);
return entry;
}